logo hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    Where does a Loop exit when done?

    Scheduled Pinned Locked Moved
    Help and Support
    5
    12
    339
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • KamdroidK
      Kamdroid @Deeeds
      last edited by Kamdroid

      @Deeeds I also don’t know.

      I just add a little delay (0.017 is the absolute lowest, thanks to Jack8680 for pointing this out) next to the start of the loop, and because the loop freezes the game until it’s finished, the delay will only finish once the loop has, thus running everything after the delay.

      0_1510964350746_0B0F158D-4B09-452A-B550-DE7709D7BA26.png

      D 1 Reply Last reply Reply Quote 1
      • iTap DevelopmentI
        iTap Development @Deeeds
        last edited by

        @Deeeds maybe it would work to have an IF and BEHAVIOR ON at the end of the loop chain and have the IF be ‘i is less than 10’ or whatever the loops is going to. So then on the last time the loop runs the behavior on can trigger whatever you want to continue with. Or you could use a broadcast instead of behavior on.

        D 1 Reply Last reply Reply Quote 1
        • D
          Deeeds @Kamdroid
          last edited by

          @Kamdroid Now THAT is hacky! Wow. What a bodgy workaround!

          1 Reply Last reply Reply Quote 0
          • D
            Deeeds @iTap Development
            last edited by

            @iTap-Development Nesting If's to get an exit! Nice! I feel so spoiled. I've come from using big, general purpose languages for a while, where there's more facilities than needed. Haven't had to think like this since I was a kid.

            We can only hope @hamed realises he shouldn't require this kind of behaviour (oh... pun) from his users.

            1 Reply Last reply Reply Quote 0
            • Jack8680J
              Jack8680 @Deeeds
              last edited by

              @Deeeds 0_1510971063690_IMG_0500.JPG

              First the behaviour named '1' will run, then '2' will repeat during the loop, then '3' will run when the loop finishes.

              D 1 Reply Last reply Reply Quote 1
              • D
                Deeeds @Jack8680
                last edited by

                @Jack8680 Another hack! Around. Literally, around the loop. Nice!

                Jack8680J 1 Reply Last reply Reply Quote 0
                • Jack8680J
                  Jack8680 @Deeeds
                  last edited by

                  @Deeeds I think this was the intended way of using them, since the behaviours just activate in order.

                  KamdroidK 1 Reply Last reply Reply Quote 0
                  • KamdroidK
                    Kamdroid @Jack8680
                    last edited by

                    @Jack8680 In the example I showed here, if I remove the delay, then the behaviour on will run before the loop finishes, and wrecks everything lol.

                    Jack8680J 1 Reply Last reply Reply Quote 0
                    • Jack8680J
                      Jack8680 @Kamdroid
                      last edited by

                      @Kamdroid the behaviour on shouldn't run before the loop finishes.

                      I don't know what your project is, but I see you're using spawn on area. When an object is spawned, its behaviours don't run until the next tick; so if appLoader_Load is doing causing those spawned objects to run behaviours then you do need a delay, although it only needs to be 0.017s I think.

                      KamdroidK 1 Reply Last reply Reply Quote 2
                      • KamdroidK
                        Kamdroid @Jack8680
                        last edited by

                        @Jack8680 Thank you, you’re correct; anything lower than 0.017 and it runs before loop finishes.

                        1 Reply Last reply Reply Quote 0
                        • MurtazaM
                          Murtaza Admin
                          last edited by

                          As jack says it will trigger the next child of the parent behaviour.
                          This is by design, since it's how every other behaviour works. They trigger in order of left to right.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post