Boolean global and local variables?

Discussion and feedback on Construct 2

Post » Tue Feb 26, 2013 11:05 pm

Still on the todo list.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,564

Post » Wed Feb 27, 2013 6:03 pm

Thanks Ashley! I also noticed that! However, using Number variables with 1 and 0 worked just fine.

Thank you for improving Construct 2 everyday!
B
17
S
4
G
3
Posts: 73
Reputation: 3,723

Post » Sun Mar 10, 2013 3:51 pm

+1 to jegcelorio
B
4
S
1
Posts: 3
Reputation: 781

Post » Mon Mar 11, 2013 1:40 pm

Numbers work just as well. The only issue is that sometimes you might accidentally set the wrong variable. Also if you have been using booleans for years it is a little weird. It's a low priority anyway but it would be nice to have :)
B
69
S
11
G
6
Posts: 324
Reputation: 8,321

Post » Mon Mar 11, 2013 4:46 pm

@mammoth: Instead of setting numbers, try setting up two new global variables: "True" with a value of 1 and "False" with a value of 0. You can then just reference True and False through your code.
B
24
S
4
G
1
Posts: 244
Reputation: 3,462

Post » Mon Mar 11, 2013 9:00 pm

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...
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Fri Nov 15, 2013 11:28 am

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!
B
24
S
6
G
6
Posts: 255
Reputation: 3,649

Post » Fri Jul 04, 2014 8:52 pm

Another reminder for global booleans. Thanks!
B
46
S
15
G
3
Posts: 199
Reputation: 4,584

Post » Mon Feb 09, 2015 6:19 am

Is global booleans being worked on yet? Or has this ship sailed?
B
30
S
7
G
3
Posts: 581
Reputation: 4,334

Post » Mon Feb 09, 2015 12:54 pm

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)
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: andreyin, Eisenhans and 12 guests