How do I "For Each Key (ORDERED)" ?

0 favourites
  • 9 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • Hi everyone,

    Their is a system condition called "For each (ordered)" it helps to put a gap between actions

    Is their a way to achieve the same result with Dictionary's "For Each key" Condition in a way that for each key actions will take place just a moment after previous key....

  • Yes there is a 'for each key' condition on the Dictionary object that will run through every key in storage.

  • I want to achieve For Each Key (Ordered)

  • Ordered by what?

  • just in their key number order, so that the actions for each key from 1 to 10 will happen one after the other and not all at the same time.

  • I may be wrong but I don't think 'key number' is data that exists. You store a key with a name and a value not an identifier. You could potentially store keys where the string is a number and run it through a loop : for from 0 to dictionary.keycount : log dictionary.get(""&loopindex) assuming keys are stored as "1", "2", "3" etc however that is not really running them in order it is checking that it exists and they happen to be in order.

  • That might work for me as my key names are numbers from 0 to 10, although i wasn't able to understand the code you came up with.

    Can you explain the code and how would it put a gap between each key's actions in order...

  • It's a loop that runs from 0 to number of keys stored. It won't put any obvious gap because it's running it all in one tick although you could try stopping and continuing the loop. If you want to wait you could try calling a function with a number sent through as a param, you add 1 to this number each time you run the function. Inside the function you 'get' the dictionary item 'param' so dictionary.get(""&param). When you've done what you need to do with the key then you add 1 to the variable you are sending through the function and call it again.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could potentially store keys where the string is a number and run it through a loop : for from 0 to dictionary.keycount : log dictionary.get(""&loopindex) assuming keys are stored as "1", "2", "3" etc

    If you want to wait you could try calling a function with a number sent through as a param, you add 1 to this number each time you run the function. Inside the function you 'get' the dictionary item 'param' so dictionary.get(""&param). When you've done what you need to do with the key then you add 1 to the variable you are sending through the function and call it again.

    I got this working, Thanks a lot for your help

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