Boolean global and local variables?

  • I almost always use int just because I find that so often I end up needing more than two states. Though simple Boolean is fine for basic scenarios, I seem to almost always end up in 3+ states that need to be represented. Not that this has anything to do with the need for a Boolean type. I am bored and the meds are kicking in...

  • I was designing some level advancement things and a global boolean would be perfect for what I'm doing. I know I can use integers but it's easier to look at the code saying "is or is not".

    Not in a hurry though, just a reminder. Something tells me that regardless of it's low priority it wouldn't be too hard to put it in.

    Thanks!

  • Another reminder for global booleans. Thanks!

  • Is global booleans being worked on yet? Or has this ship sailed?

  • For people trying to do booleans for right now here's two methods...

    Method A:

    If myVariable = 0 (IF FALSE)

    If myVariable = 1 (IF TRUE)

    Set myVariable = 1 - myVariable (TOGGLE BOOLEAN BETWEEN 1 AND 0)

    Set myVariable = 0 (FALSE)

    Set myVariable = 1 (TRUE)

    Method B:

    If myVariable = -1 (IF FALSE)

    If myVariable = 1 (IF TRUE)

    Set myVariable = myVariable * -1 (TOGGLE BOOLEAN BETWEEN 1 AND -1)

    Set myVariable = -1 (FALSE)

    Set myVariable = 1 (TRUE)

  • For people trying to do booleans for right now here's two methods...

    Method A:

    If myVariable = 0 (IF FALSE)

    If myVariable = 1 (IF TRUE)

    Set myVariable = 1 - myVariable (TOGGLE BOOLEAN BETWEEN 1 AND 0)

    Set myVariable = 0 (FALSE)

    Set myVariable = 1 (TRUE)

    Method B:

    If myVariable = -1 (IF FALSE)

    If myVariable = 1 (IF TRUE)

    Set myVariable = myVariable * -1 (TOGGLE BOOLEAN BETWEEN 1 AND -1)

    Set myVariable = -1 (FALSE)

    Set myVariable = 1 (TRUE)

    Even easeir

    myVariable = 0

    X myVariable = 0

  • Toggle:

    Set MyVariable = (MyVariable + 1) % 2

    Normal use, just set it to 1 or 0....

    Although not intuitive, there are bigger things that the editor/engine needs IMO.

  • easy method then variables just ad a sprite(can be you play button, main actor, a text something that stays on screen always and u don't destroy it ) and create a boolean for it , and make that sprite global now u have global boolean's ....... works for me , just i'm not using global boleans never needed one

  • easy method then variables just ad a sprite(can be you play button, main actor, a text something that stays on screen always and u don't destroy it ) and create a boolean for it , and make that sprite global now u have global boolean's ....... works for me , just i'm not using global boleans never needed one

    Good idea, are global sprites limited in any way that global variables aren't or are they all exactly the same?

  • Necrobump!

    I'm just starting out with C2 and noticed this immediately (while implementing a work around for touch triggers firing ~simultaneously). Please address.

  • * bump *

    Yes we can do booleans with numbers, but it's not the same

  • i agree... integers take 4 bytes, bools 1 bit

  • We have 2016 and it's still not implemented.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also just realised they are not there :'(

  • Would it be an issue for it to be rolled out for a quick update?

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