How do I stop a dictionary for each loop?

0 favourites
  • 4 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • This is what I try:

    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.

  • This works:

    ... but it seems like I'm going around my elbow to reach my nose.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)