Set boolean via an evalutaion

Get help using Construct 2

Post » Sun Nov 27, 2011 7:28 am

Hi, with boolean instance variable it seems we can only set them manually to specifically true or false. Instead of the drop down can we rather have an expression that resolves to either true or false depending on the result?
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sun Nov 27, 2011 10:57 am

is "toggle boolean" action not what your looking for? it will set to true or false depending on current setting
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Sun Nov 27, 2011 11:08 am

Not really, imagine this pseudo code: Boolean value = sprite.Y >10

This would dynamically set the Boolean to True or False depending on the result of the expression (if sprite.Y is greater than 10 or not).


Toggle just switches from true to false depending on it's last state.

jumprock2011-11-27 11:09:51
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sun Nov 27, 2011 12:07 pm

don't quote me, but i think you can define a variable that would equate to that expression. would that operate the way you want?
B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

Post » Sun Nov 27, 2011 2:22 pm

There's not currently a way to do that directly, but the workaround is simple - just use conditions:

+ Sprite Y > 10
-> Set boolean to true
+ Sprite Y <= 10
-> Set boolean to false
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sun Nov 27, 2011 5:46 pm

yeah...what he said...lol.
B
50
S
17
G
15
Posts: 1,029
Reputation: 26,289

Post » Sun Nov 27, 2011 10:43 pm

OK. Not sure if you can answer this, but is the general game plan for Construct to eventually add all of this sort of flexiblity and functionality, or to keep it quite locked down in order to maintain simplicty for non programmer types?
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Sun Nov 27, 2011 11:53 pm

Yeah, there's no reason not to have this, it's on our todo list, we're just super busy and it takes time to get round to this type of thing, and if it's not urgent (i.e. there's a really easy workaround, which there is) then we usually make it a lower priority.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Nov 28, 2011 12:02 am

Thanks for the reply Ashley - I totally understand!
B
16
S
5
G
1
Posts: 43
Reputation: 1,595

Post » Mon Nov 28, 2011 12:07 am

In the mean time a number variable could be used. 0 for flase, 1 for true.
B
79
S
24
G
53
Posts: 4,735
Reputation: 40,233

Next

Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 28 guests