0 Favourites

Why no local or global boolean variables?

  • 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).

  • > 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.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Silverforce - 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)
Similar Topics Posts Views Last Post
Unread hot topic
163 20,243
iBarin's avatar
iBarin
Unread hot topic
112 12,479
Pode's avatar
Pode
Unread hot topic
102 6,404
Ashley's avatar
Ashley Construct Team Founder