[Solved] Loop over table doesn't work if placed within a rule.

xwrbnxxwrbnx Member Posts: 23
edited June 2015 in Working with GS (Mac)

Hi all,

I am trying to use Loop Over Table to spawn a list of actors I store in table. I have a master actor to do this job. So when I put the Loop Over Table on master actor (not contained in within any rule), it works perfectly.

However, when I put it in a rule when master actor received touch is pressed, the Loop Over Table does not work at all.
Or when I put within a rule to check against certain attribute, it does not work too.
It only works when the actor is spawned or in the beginning only.

Does anybody have the same experience? How to solve this issue? I need to run the Loop Over Table on certain condition.

Please advise. Thank you.

Best Answer

  • tatiangtatiang Posts: 11,949
    edited June 2015 Accepted Answer

    Putting a time-consuming behavior such as Loop Over Table inside of a When Touch is Pressed rule won't work because you'd have to hold down the button until the loop has completed for it to work properly. Try this:

    When Touch is Pressed
         Change self.startLoop (boolean) to true

    When attribute self.startLoop is true
         Loop Over Table

    I'm guessing you're running into a similar problem when checking for the value of an attribute... if that value changes quickly, the loop won't have time to complete. If you're still stuck, post a screenshot of your rules (upload the image to a file-sharing site and then paste/embed the link here).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Answers

Sign In or Register to comment.