Colobot Forum - International Colobot Community
Boolean values in scene files - Printable Version

+- Colobot Forum - International Colobot Community (https://colobot.info/forum)
+-- Forum: [Archive] New forum (2015-2019) (https://colobot.info/forum/forumdisplay.php?fid=76)
+--- Forum: Colobot: Gold Edition Development (https://colobot.info/forum/forumdisplay.php?fid=62)
+---- Forum: Game Engine & General Talk (https://colobot.info/forum/forumdisplay.php?fid=63)
+---- Thread: Boolean values in scene files (/showthread.php?tid=614)



Boolean values in scene files - krzys_h - 05-30-2015

The new scene parser that was added some time ago supports a new way of defining boolean values.

In original colobot, there was no real boolean values, just numbers - 0 for false, 1 for true.
Now, you can actually use true/false for these values.

Code:
CreateObject selectable=0     // old syntax
CreateObject selectable=false     // new syntax

My only question now is: Should the true/false become the new recommended standard used in default Colobot scene files, or should we keep using 1/0?


RE: Boolean values in scene files - RaptorParkowsky - 05-30-2015

I think there should be support for both standards. There's sometimes other options than 0/false and 1/true, like 2, 3 etc. True/False standard is more human-friendly, but it have one disadvantage - it's longer and creates more not really necessary bytes in text file.


RE: Boolean values in scene files - Simbax - 05-30-2015

If a scene file is created by a human, then use true/false, if a scene file is created by an editor, then use 1/0. It doesn't really matter, though. It's the same situation as with some guys preferring to write code like that:

Code:
void f() {
   return;
}

or like that:

Code:
void f()
{
   return;
}



I have a question if does it work the following way: 0 is false, any other value is true?


RE: Boolean values in scene files - krzys_h - 05-30-2015

(05-30-2015, 04:43 PM)Raptor Wrote: I think there should be support for both standards.
Both standards are supported, I'm just asking which should be the preferred one.

(05-30-2015, 05:42 PM)Simbax Wrote: I have a question if does it work the following way: 0 is false, any other value is true?
I'm not sure. It's whatever boost::lexical_cast uses. It's probably either 0 = false, anything else = true or 0 = false, 1 = true, anything else = level loading error.
In the old implementation this really depended on the actual command (some did if(param == 0) {} else {}, others did if(param == 1) {} else {}). It's more standarized now.