Setting local boolean variables

Post » Wed May 24, 2017 1:34 pm

I intend to use (local) boolean variables to keep some intermediate results from a number of calculations, but can't find how to set the value of the local variables that I want to use. I can't use System->Set value, since the boolean local variables aren't shown in the variable drop down list. I can't use System->Set boolean either, since then I am ony allowed to choose between True and False and can't enter an expression which is what I want.

How should I do this? Most likely I am missing something simple!
Posts: 3
Reputation: 1,756

Post » Wed May 24, 2017 3:13 pm

Hi. At the risk of being wrong in your case; I was also struggling with this the other day. In my case, the local variable was a property of an object and therefore within an event I had to add Action>Pick Object>toggle Boolean>select instance variable from list
Scirra Employee
Posts: 1
Reputation: 327

Post » Wed May 24, 2017 3:36 pm

That sounds about right. Cant set them to an expression in the current version of c3.
That hit me too.

Got to couple them to a condition.

Condition ... testing an expression
_____ set boolean
______unset boolean.

Got to be careful with the logical part of that condition. The 'else' runs only if its parent did not run. (is false)

Those conditions that start with 'Is ....' are conditions that return a 'false/true' as result.
The conditions that pick return a 'false/true' if the picklist is empty.
Those that start with 'On ....' have no 'else', they are triggers.

Whats left, is those that start with 'Compare .....'.
You can compare in two ways.

Say ...
Regular way. Comparing two expressions that hold a value (Sprite.x ... 5000 .. pi ... sin(90) ...etc)

Using logical expressions.
Value one = Sprite.x > 50 & Sprite.x < 200
Value two = 1

Construct takes '0' as false when using logical expressions. And '1' as true.

You can also use logical expressions like this.
Sprite.X = 1? 1 : 0
Returns 1 if Sprite.X = 1 else 0.
Posts: 2,493
Reputation: 21,450

Return to General Discussion

Who is online

Users browsing this forum: rayray and 0 guests