Are neutral 3 state flags a thing?

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Flags are obviously extremely handy but some times I have wished for a third state of the flag. We now have On or Off, but a Neutral state would also be useful in some conditions. I wonder if this is a thing and something that exist in the coding realm and something that could perhaps be incorporated in Fusion?

    Steam games: Please login to see this link.

  • Few options that (depending on what you're trying to do) might work:

    1. An alterable value and just set it to something like -1/0/1 for on/neutral/off. If you multiple the alterable value by -1 it will toggle between on and off, if it's neutral then 'toggling' by multiplying -1 will do nothing. This one probably has the most flexibility/easiest to change values on the fly

    2. A string that you just changed to "on", "off' and "neutral". easier to read at first glance but manually changing between each state would need a few events (or child events)

    3. Using two flags, with Flag 1 being "on/off" and flag 2 being "neutral/not neutral". Whenever flag 2 is 'neutral' you could ignore the value in flag 1. Probably the fiddliest way to do it, but if you need to use flags instead of values/strings for some reason it could work

  • I've no idea about what it's like in other languages. But I use a lot of altVals that are either -1, 0, or 1, which although not the same as what you're talking about, is probably similar. And there's a handy equation you can use to force any number to be one of these 3 numbers.

    For example, say you have a character that moves left or right. Her speed is determined by an altVal called xSpeed, which can be various values (eg. 20=moving fast to the right, -1.46=moving slowly to the left, 0=standing still). Let's say you want a 'flag' that can simply show whether she's moving left, right, or standing still. Well, you can get this with the equation xSpeed / abs(xSpeed).

    If xSpeed is any negative number, it will return -1. If xSpeed is any positive number, it will return 1. If xSpeed is 0, then it will return 0 (in most languages, this equation would hit you with a divide by zero error, but Fusion is friendlier, so it just gracefully returns a zero).

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

  • Thanks for the ideas and I understand most things are possible to do with workarounds and some of these are really neat, especially the xSpeed / abs(xSpeed) is something I will def use!

    But yes would just be nice also with an option for a simple 3 state flag is my point :)

    Steam games: Please login to see this link.

  • In the "realm" of programming languages, flags are the equivalent of a boolean (Please login to see this link.) which are true or false only.

    Fusion stores flags in a 32bit number. If flag 0 and 3 is enabled, that would be represented in binary like so: 0b00000000000000000000000000001001
    Since one flag occupies one bit and there's 32 bits to work with you get 32 flags to use. Bits can only be off or on, so there's no space to fit a neutral state without modifying flags in a major way and breaking compatibility.

    I wonder if there's a mathematical way of doing this to toggle between -1 and 1 X)

    multiply by * -1? :)

    - BartekB

    Join the Click Converse Discord! - Please login to see this link.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!