How do I…
What is the expected result
there’s a scene variable Turn that i need to toggle between 1 and 2 using a button, and a text box that displays current value of Turn.
What is the actual result
nothing happens.
What’s happening is that the first variable sets the variable from 1 to 2. However, this meets the second event’s conditions and subsequently subtracts 1 from the variable, setting it back to 1.
To fix this, get rid of the 2 subevents, and add the following action to the “Button_EndTurn” event:
“Change the variable Turn: set to mod(Turn + 1, 2) + 1”
This uses the modulus operator to flip between 1 & 2.
I tested it and it doesn’t work.
mod(Turn + 1, 2) + 1
(Turn=1)
mod(Turn + 1, 2) + 1
mod(1 + 1, 2) + 1
mod(2, 2) + 1
0+1
1
I had to Google it bc mod() drives me crazy.
This works.
Turn = mod(Turn, 2) +1
Ah, my bad. Thanks for catching it.
i’m almost done with my fisrt game and you guys have no idea how much this helped. you;re the real troopers, thank you so much o7