Running loop in background while other events occur?

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.
  • Can this be done? I love using loops, but when I need to loop through an extremely long list of data, the program naturally pauses until the loop is finished. What's the best way to have a "background" loop which doesn't stop the execution of other events?

  • This is known as 'multithreading'. In short, MMF2 doesn't do it. But you could do it by having the 'long' loop run by an external program that is loaded by the main program, then returned to it. Otherwise, as tompa says, you could just spread it out into bite sized chunks

  • lol :)
    Thanks, but it really isn't complicated.
    Suppose you want to run a fastloop to count from 0 to 99 (100 loops), but you want to spread it across 5 frames:

    + ChunkNumber < 5
    -> Start fastloop "CountTo100", 20 times
    -> Add 1 to ChunkNumber

    + On loop "CountTo100"
    -> Set Counter to (ChunkNumber * 20) + LoopIndex("CountTo100")

    The value of the counter becomes your "overall" loop index.

  • Although not using fast loops, you may want to consider using a group event. Have the actions that you would like to have looped inside of a group event. Activate the group event when you want to start the sequence. This will iterate through the logic one time for each pass of code. Deactivate the group when you have cycled through the loop criteria.

  • I think you could, but a better way of doing it is make it so that the first event in the group of events starts a fastloop, and then put every event in the event group into said fastloop, so that you can do the loop chunking more easily (the number of times you run the loop is a loop speed multiplier if you do it this way, basically).

    My Please login to see this link. (which I actually use), my Please login to see this link. (which I mostly don't use), and my Please login to see this link. (which I don't use anymore pretty much at all really). If there are awards for "'highest number of long forum posts", then I'd have probably won at least 1 by now. XD

Participate now!

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