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?
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.
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.
-
-
One way is to spread work over several rendered frames. Make one small iteration every gameloop.
-
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
-
Thanks for the fast replies. Those are two interesting methods. I assume that having a separate, invisible program to perform the loops is the fastest method.
-
I would definitely go with just spreading the loops across multiple frames. There's even the "Useful Fastloops" extension you could use, which has a "chunked fastloop" feature if you can't be bothered to code it yourself (which would be very easy anyway).
-
For you, anyway. You damned genius, you
-
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.
-
Thanks for the info about the chunked fastloops. I'll have to do some tests with it to find the right chunk size for my program.
-
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.
-
Thanks, rubes. With this kind of approach, couldn't I increase the "loop" speed by increasing the program's frame rate?
-
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).
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!