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?
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.
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.
-
-
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).
-
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
-
Using strings for clearity in code is also something I like, but I am a little worried about the performance impact and it is something worth taking into notice.
-
And *if not it.. edit..
-
I wonder if there's a mathematical way of doing this to toggle between -1 and 1 X)
-
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?
-
That was easier than expected :V
I actually know this, but I shut off my brain while thinking of the craziest ways of accomplishing the same thing xD -
So basically you want Please login to see this link.
-
How about a qubit flag? Then you could define as many states as you want.
-
You're really suggesting quantum physics? lol
I mean, I don't think that's even possible in a computer that's not using a quantum CPU. -
No not really, just kidding.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!