Why no local or global boolean variables?

0 favourites
  • 13 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • But Why?

  • But Why?

    If you try Search you'll find that Ashley admitted it was just an oversight and has been on the todo list for a while.

  • because setting an integer variable to 0 or 1 is the same thing,

    though i think it should reduce a bit of code, instead of checking if something == 1 or 0 , you could do if (var) -> do something,

    because booleans by default have false or true only. wouldn't affect performance, only would be easier to write a line.

  • I agree, and setting a variable to 1 or 0 is simple enough, of course, whether it's a boolean or not. A simple work around for of you need to toggle a boolean/ivariable without having to check it first:

    Variable1 = (Varable1 + 1) % 2

  • Or just make global object with boo's. I am actually finding this much more comfortable then if I'd have to scan trough globals and locals.

  • Or just make global object with boo's. I am actually finding this much more comfortable then if I'd have to scan trough globals and locals.

    Well, I must admit I do that as well. lol. In large projects its no good to use global variables. There are too many of them and no way to organize them. But I would like to use local variables. They are a bit more meaningful than saying set TempObject.TempBoolean to false

  • because setting an integer variable to 0 or 1 is the same thing,

    though i think it should reduce a bit of code, instead of checking if something == 1 or 0 , you could do if (var) -> do something,

    because booleans by default have false or true only. wouldn't affect performance, only would be easier to write a line.

    I didn't know that. Thank you! (Not a sarcastic response).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • > Or just make global object with boo's. I am actually finding this much more comfortable then if I'd have to scan trough globals and locals.

    >

    Well, I must admit I do that as well. lol. In large projects its no good to use global variables. There are too many of them and no way to organize them. But I would like to use local variables. They are a bit more meaningful than saying set TempObject.TempBoolean to false

    I'm calling that object just SYS . I use local vars too. Depends what is needed.

  • > Or just make global object with boo's. I am actually finding this much more comfortable then if I'd have to scan trough globals and locals.

    >

    Well, I must admit I do that as well. lol. In large projects its no good to use global variables. There are too many of them and no way to organize them. But I would like to use local variables. They are a bit more meaningful than saying set TempObject.TempBoolean to false

    I must have around 600 global variables. With a good naming system, they are manageable.

  • - With a good naming system, it is true... But I would postulate that the better the names the longer it takes to type. In a programing language, these variables would be better split among objects or static singletons that are a snap to access.

    In Construct -

    LevelSpawnPlayerType = something.

    in c#

    level.Spawn.Player.Type = something.

    Autocomplete doesn't work in construct until you get far enough. LevelSpawnPLayerT... if another variable LevelSpawnPlayerLocationX or LevelSpawnEnenmy... or som on exists. In other IDE, splitting the variables up allows you to access them using auto complete which would function at each level of organization. That's the primary reason I stick them in objects as opposed to using globals. Also, the variables clutter up your expressions list every time you start typing in expressions. But if it works for you the way you do things, great, keep it that way!

    I should also point out I suck at typing and the more help I get the better. Too slow! I fail at typing in the same way. lol

  • Ruskul I do believe you can split global variables as if they were contained within objects. I can't remember how though.

  • Whilst you can recreate a boolean with a global numeric variable - by far the best feature of the boolean, toggle, is missing.

    Sure you can work around it, but as a guy who uses booleans a lot, I'd love to see the global boolean make it's appearance at last.

  • Ruskul I do believe you can split global variables as if they were contained within objects. I can't remember how though.

    Really? I must look for this then. It was one of my biggest quams with using them.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)