Problems with LOOP

I'm trying to cycle from 1 to 30 and reset level lock.

I set game.tempInt to 2

Then I loop while (all) attribute game.tempInt <= 30

I have my commands in the loop, including a change attribute game.tempInt = game.tempInt+1

Among the commands is a log statement (the first statement in the loop). It never gets executed.

Am I setting up the loop behavior correctly?

I've also tried loop until tempInt > 30 and that doesn't work either.

Using Mac 13.8.0

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Can you post a screenshot of your Loop behavior?

  • ookami007ookami007 Member Posts: 581

    Let's see if this works...

  • SummationSummation Member, PRO Posts: 476
    edited April 2015

    @ookami007 said:
    Let's see if this works...
    [image]

    How are you keeping track of your WhichOne attribute?

  • ookami007ookami007 Member Posts: 581

    That's set at the top and doesn't change. When I run the change table value outside of the loop, it works.

  • SummationSummation Member, PRO Posts: 476

    @ookami007 said:
    That's set at the top and doesn't change. When I run the change table value outside of the loop, it works.

    So you can click manually and have it do what you want, but it just won't work when you try to do the loop?

  • ookami007ookami007 Member Posts: 581

    That is correct.

  • SummationSummation Member, PRO Posts: 476

    @ookami007 said:
    That is correct.

    Have you tried clicking more than once, to see if it will do what you want all the way to the end?

  • ookami007ookami007 Member Posts: 581

    The loop doesn't seem to be kicking off at all. Even with a log statement as the firs thing in the loop I don't see it kicking off.

  • ookami007ookami007 Member Posts: 581

    At the end of the click event, it changes scenes.

  • SummationSummation Member, PRO Posts: 476

    @ookami007 said:
    The loop doesn't seem to be kicking off at all. Even with a log statement as the firs thing in the loop I don't see it kicking off.

    Are there any other behaviors in your actor besides the ones shown in the screenshot?

  • ookami007ookami007 Member Posts: 581

    Tons... and they are all working. Basically, I resetting all the player stats (there's a lot). All are working except the loop.

  • SummationSummation Member, PRO Posts: 476

    @ookami007 said:
    Tons... and they are all working. Basically, I resetting all the player stats (there's a lot). All are working except the loop.

    Ok, try making a new actor and tell it, when touch is pressed do loop.
    This may help you isolate the problem and rule out any other conflicting behaviors.

  • ookami007ookami007 Member Posts: 581

    You'd think it would run at least once.

  • SummationSummation Member, PRO Posts: 476

    @ookami007 said:
    You'd think it would run at least once.

    So you put the loop in its own actor and it doesn't run at all?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    A couple things about your rules:

    1. It looks like your Loop behavior is inside of another rule. If that rule stops running, the Loop won't work properly. An example of this is When Touch is Pressed --> Loop. Since the "touch" is very brief once released, the Loop won't complete.
    2. Why not just use a Loop Over Table behavior since that's what it's intended for?

    Here's a demo where I tried to match your rules. It logs each iteration of the loop. Maybe you can determine what's different when compared to your file.

  • ookami007ookami007 Member Posts: 581

    So what if I spawn another actor with the loop behavior in it. Will it run all the way through at that point?

    I'll play around with the Loop Over Table, but I'm not up on how it works.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    @ookami007 said:
    So what if I spawn another actor with the loop behavior in it. Will it run all the way through at that point?

    Yes, assuming the Loop behavior is not inside of a rule (or is inside of a rule that doesn't get interrupted).

    I'll play around with the Loop Over Table, but I'm not up on how it works.

    @Braydon_SFX has some great table tutorial videos in this thread: http://forums.gamesalad.com/discussion/comment/442821//p1. You might check out this video: http://forums.gamesalad.com/discussion/comment/442821/#Comment_442821. I'm not sure if he used Loop Over Table, though.

Sign In or Register to comment.