ExpiredReign
Deity
I'm trying to understand how booleans are parsed (I think that is the term) by Lua when they are defined a number of different ways.
eg.
In CIV5Buildings.xml the defining of a number of tables are laid out and most of the booleans are done like:
but some are defined as:
Now when you examine these tables with SQLiteSpy all the booleans defined in the first manner are 0 or false, unless later modified to be 1 or true. Whereas the booleans defined in the second manner are empty or null, unless changed to 1 or true.
What I want to know is, if you have Lua code that makes a check of a boolean, expecting it to be 0 or false, and it finds it as null, as the second table example shows it, won't that produce an error?
Secondly, I have found that the Notifications table, as examined with SQLiteSpy, shows the booleans defined there as "false" or "1". If someone wrote Lua code that asked if a value was false this way:
(don't pick on the poor code)
Would it fail because the value was stored as "false"? Or are these values recognized as booleans no matter which manner they are stored?
eg.
In CIV5Buildings.xml the defining of a number of tables are laid out and most of the booleans are done like:
Code:
<Column name="ArtInfoRandomVariation" type="boolean" default="false"/>
Code:
<Column name="RequiresUniquePlayers" type="bool"/>
Now when you examine these tables with SQLiteSpy all the booleans defined in the first manner are 0 or false, unless later modified to be 1 or true. Whereas the booleans defined in the second manner are empty or null, unless changed to 1 or true.
What I want to know is, if you have Lua code that makes a check of a boolean, expecting it to be 0 or false, and it finds it as null, as the second table example shows it, won't that produce an error?
Secondly, I have found that the Notifications table, as examined with SQLiteSpy, shows the booleans defined there as "false" or "1". If someone wrote Lua code that asked if a value was false this way:
Code:
if someValue < 1 then...
Would it fail because the value was stored as "false"? Or are these values recognized as booleans no matter which manner they are stored?