Hi Guys,
Representation of my Loop Problem:
Variable X,Y,Z = 0
Condition 1: Repeat 10 Times
Condition 2: Y < 100
Add to X 20
Add to Y 50
Add to Z 100
What I want is to exit the loop when Y becomes 100, without executing the 3rd Action (Add to Z 100)
The Desired result is:
X= 40 (Action Add to X Executed twice)
Y=100 (Action Add to Y Executed twice before the condition fails)
Z= 100 (Action Add to Z executed once since the condition failed)
The Result I get from Construct2:
X=40
Y=100
Z= 200 (All 3 actions in the loop were completely executed before checking for the condition)
I have tried different approaches- None of them worked:
1. Outside loop, I've set System Event to "Stop Loop" if Y >=100
2. Outside loop, I've set System Event to "Deactivate Group" in which loop is if Y >=100
Now I understand that all the actions will be performed before checking the condition for loop.
My Question is : Is there a way to exit the loop without performing all actions when a condition is met. To solution I'm looking for is as follows:
Repeat 10 Times
Add to X 20
Add to Y 50
IF Y >= 100 Exit Loop
Add to Z 100
Is this possible through Construct2? Or do I have to code it in Javascript in C2runtime.js?
This is simplistic representation of the problem I have at hand. I want to apply this logic to show user's friends' photos dynamically in a facebook game.
Any help will be much appreciated.
Thank you.
Capper33