Nested loops question

Get help using Construct 2

Post » Tue Jul 02, 2013 8:53 pm

Say you make a nested loop with one inner, and one outer loop. How do you make an action happen after the inner loop runs? Like, say I wanted to increment a number every time the inner loop runs through, but I don't want the number incremented until after it has actually ran?
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Tue Jul 02, 2013 9:18 pm

X is a variable

X = 0 or whatever value you need it to start at.

Try this:
"For X to 100"
---"For 0 to 10"
---"Do whatever in the inner loop"
Add 1 to X

(You can just add a blank event underneath the inner loop, and it will run when the inner loop is done.nimos1002013-07-02 21:20:14
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Wed Jul 03, 2013 1:38 pm

That's all great until you get to the part where you "add 1 to X". C2 doesn't seem to allow me to put an action within a loop after the inner loop, but before leaving the scope in which the inner loop exists. I am using the "repeat X times" loop events. Would using a different type of loop make a difference?
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Wed Jul 03, 2013 1:50 pm

[QUOTE=Yttermayn]Would using a different type of loop make a difference?[/QUOTE]

Nope. Select your repeat event, and press B. It will create black sub-event for the repeat event, now you can add whatever you wish to that.
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Wed Jul 03, 2013 1:57 pm

Oooh, that's a dang handy shortcut! Thanks!
B
11
S
4
G
1
Posts: 159
Reputation: 1,803

Post » Wed Jul 03, 2013 8:31 pm

Ok, thanks guys. I got it working, there was another bug interfering with what I was doing that made things more difficult to sort out. Thank you both, you were very helpful in this matter.
B
11
S
4
G
1
Posts: 159
Reputation: 1,803


Return to How do I....?

Who is online

Users browsing this forum: NN81 and 2 guests