How do I stop a dictionary for each loop?

Get help using Construct 2

Post » Sat Jul 12, 2014 2:20 am

This is what I try:
Image

First event does what I expect, loads a dictionary object with 10 items:
"loopindex1":1
"loopindex2":2
"loopindex3":3
"loopindex4":4
etc...

Now I try to run a for each loop on the dictionary and stop at '5'. I tried both methods above, neither works.

How can I break out of a for each loop on a dictionary? There is no stop loop action on a dictionary object? I need a little help, please.
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Sat Jul 12, 2014 2:37 am

This works:
Image

... but it seems like I'm going around my elbow to reach my nose.
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Sat Jul 12, 2014 2:41 am

If your keys really are numbers, you can just use the "For 1 to 5" event and use Dictionary.Get("loopindex"&loopindex). If not, you'll just have to track the range manually and only perform the Action when appropriate.
The System loopindex and Stop action have nothing to do with the Dictionary object.

Edit: you updated as I was writing. "KeyIndex" from 1 to 5 is all you need here.
ImageImageImage
B
71
S
21
G
221
Posts: 3,650
Reputation: 124,229

Post » Sat Jul 12, 2014 2:49 am

Thanks ... I understand. In my actual program my keys are words and the values are different scores. It just seems odd there is no clean way to break a dictionary for-each action.
B
11
S
2
Posts: 86
Reputation: 1,001


Return to How do I....?

Who is online

Users browsing this forum: alextro, Ryan Kocourek and 2 guests