Order of Events for Loops

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • I asked about the order in which events will occur for fastloops and ForEach loops for MMF2, and nobody would give me an answer besides, "Test it". So I'm making this post, after a long time without posting, to show you the answer to my question, so you don't have to test it yourself. To start with, here's the .mfa file I used to test it with: Please login to see this attachment. and for those of you that can't open it for whatever reason, here are some screenshots of the setup for the test.
    Please login to see this attachment.


    Please login to see this attachment.


    Here are the results of this test. Where the longer numbers are the fixed values of each of the objects being listed on each event, and the numbers are the number of which event is being run in the fastloop.
    Please login to see this attachment.
    Hopefully this has helped some of you in some way, if you have had a problem dealing with this but were unable to understand my explanation, feel free to PM me.

  • That's interesting, thanks. I wouldn't have expected the for each loop to work that way exactly, although it does make sense

    (I've never used a for-each loop so I have no experience with them at all)

  • It would seem like the foreach runs 1 event x loops before it moves to the next event, but take a look at the modification I made. The issue is that the object's iteration is not being considered. Personally, I've avoided using foreach because of its lack of support for qualifiers (it's the only extension I've found that doesn't support them, which beats its purpose completely).

    Please login to see this attachment.

    Please login to see this link. - Metroidvania RPG (Win/OSX/linux & PS4/Vita/Wii U)

    Edited once, last by Alonso (January 14, 2013 at 2:02 PM).

  • Alonso: The ForEach extension has supported qualifiers for ages now - you probably just need to update your copy.

    Anyway...
    I'm not sure why you're having problems with this - it's pretty straightforward.

    Line 1 - MMF2 starts the ForEach loop.
    MMF2 picks the first object (the order, like everything else in MMF2, is based on the order in which the objects were created, or for objects created at edittime, on their display order).
    MMF2 scans through the complete event list from top to bottom, processing every event with a "on ForEach loop" condition, in the order in which they appear in the event list.
    Once MMF2 reaches the end of the event list, that is one iteration done.
    MMF2 then moves onto the next object and starts again.

    It's just the same as with fastloops.

  • Something else I'd like to point out is that the ForEach loop is using the same object each time, but since it's a different instance of the object it has a different fixed value. So it loops through the first object for each event and then loops through the second object for each event. And therefore the ForEach Loop does indeed work the same as the fastloop, even though the picture might not show that very well. The ForEach loop did this: Event 1 object 1, event 2 object 1, event 1 object 2, event 2 object 2, and the Fastloop did this: Event 1, event 2, event 1, event 2, as you can see the event order is the same, the only thing that changes is which objects are being selected.

    Oh CRAP I have work I need to be doing, bye!

  • "Immediate" conditions (the ones written in red), are all handled in exactly the same way, and really loops aren't anything special - they're just actions that trigger an immediate condition, that's all.

    The main use of the fixed value in ForEach loops, is for creating nested loops.
    For example, one way to make each of multiple player objects look towards their nearest enemy, would be by using nested ForEach loops like this:

    + Always
    -> Player: Set StoredDist to 99999999

    + Always
    -> ForEach: Start ForEach loop "PlayerLoop" for Player

    + On ForEach loop "PlayerLoop" for Player
    -> ForEach: Start ForEach loop "EnemyLoop" for Enemy

    + On ForEach loop "EnemyLoop" for Enemy
    + Player: Fixed value = LoopFV( "ForEach", "PlayerLoop")
    + Player: StoredDist > distance from Player to Enemy
    -> Player: Set StoredDist to distance from Player to Enemy
    -> Player: Look in the direction of Enemy

    Similarly, it's possible to nest fastloops inside ForEach loops, and vice versa.

    Edited 2 times, last by MuddyMole (January 15, 2013 at 1:57 AM).

  • Alonso: The ForEach extension has supported qualifiers for ages now - you probably just need to update your copy.

    Anyway...
    I'm not sure why you're having problems with this - it's pretty straightforward.

    Line 1 - MMF2 starts the ForEach loop.
    MMF2 picks the first object (the order, like everything else in MMF2, is based on the order in which the objects were created, or for objects created at edittime, on their display order).
    MMF2 scans through the complete event list from top to bottom, processing every event with a "on ForEach loop" condition, in the order in which they appear in the event list.
    Once MMF2 reaches the end of the event list, that is one iteration done.
    MMF2 then moves onto the next object and starts again.

    It's just the same as with fastloops.

    Hi MuddyMole,

    Do you know if the foreach is working with qualifiers in flash?

    Regards,


    Fernando Vivolo

    ... new things are coming ...

  • I can confirm it does and it doesn't. It's a trick one to narrow down using 'ForEach Group' but my results were very inconsistent, I have been meaning to get something together for Ross to take a look at. My final answer on what I have seen/done would be no, best to just iterate through each object as opposed to a qualifying group (for now anyway)

    Game Launcher Creator V3 - Please login to see this link.
    Bespoke Software Development - Please login to see this link.
    Learn Clickteam Fusion 2.5 - Please login to see this link.

    Danny // Clickteam

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!