Printing out hashtable values

This forum is currently in read-only mode.
  • Hey all,

    I'm trying to go through the different areas of Construct and learn how they work. Right now I'm looking at processes. As you can see from the pic below, I'm simply populating a hashtable and then trying to print out each value. The hashtable is fine (there are only 37 keys), but when I do this last event:

    For each key ... EditBox: Append text Hashtable.CurrentKey.Newline

    instead of printing out the list once, it goes into an endless loop and prints the keys over and over...

    I've looked at the different hashtable examples on here and it hasn't helped out. Any ideas?

  • Its hard to say with no cap but it you just have a for each with no other condition it will run every tick. you need to put a trigger once in there.

  • Thanks! I added a mouse click trigger and that solved the problem. I guess I don't fully understand why a For Each Key would run every tick, but I'm not that familiar with the event system yet. Once I get the hang of all this mundane stuff, hopefully I'll make a really cool game.

  • All events are run every tick if the conditions are meant then the actions are done. For each is a condition and it has no other qualifiers so it will always run. If you add another condition to that then once Both of the conditions are meant it will .

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "For Each" is a loop. Think of your events like so:

    1. Top of event sheet
    
    2. Do some stuff
    
    3a. Loop fifty times                  <--- this is your For Each
        3b.  Do stuff fifty times
        3c.  Go back to 3a fifty times
    
    4. Do some more stuff
    
    5. Go back to Top of event sheet
    [/code:26vsc4mx]
    
    The event sheet is read from top to bottom, and then starts over again.  Since the whole event sheet itself is a loop, then the For Each is basically a loop within a loop.  As Aeal said, barring any other conditions, a For Each loop will trigger each time Construct reaches it in the order of events.
  • Thanks guys. That clears things up really well!

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