can anyone give a clear and concise tutorial on how to use fast loop as I cannot get my head round it at all.Some examples would be appreciated.Thanks in advance.


can anyone give a clear and concise tutorial on how to use fast loop as I cannot get my head round it at all.Some examples would be appreciated.Thanks in advance.

I'll have a go for you.![]()
Basically when you start a loop using an action MMF2 will look for all the conditions which have "On Loop" in them.
So it is like a function object. It took me a while to work out how to use it.

[size:14pt]Fastloops[/size]
Fastloops are immensely cool. The purpose of this article is to show why they happen to be so immensely cool, and how we can use them to coolify our programs!
Before we start, we need some background info on how MMF2 works. This will show you why we need fastloops...
[size:11pt]Event Loops[/size]
Look at your event list. MMF is reading this list from top to bottom all the time. When it comes to the end, it redraws the screen and starts reading the events all over again.
Each time MMF reads the whole event list, it has performed one 'Event Loop'.
However... redrawing the screen takes ages (in computer terms at least). Since the next event loop won't start until the redraw is complete, event loops are REALLY slow.
This normally isn't a problem, but sometimes you need to process things faster. That's where fastloop saves us.
[size:11pt]Fast Loops[/size]
Imagine this:
MMF is reading through the event list. Suddenly, it comes to a an action saying "Start loop 'blah' 100 times"
MMF now changes its behaviour slightly. It remembers where it was, and then starts looking for any events which start with the condition "On Loop 'blah'". It runs these events as it comes to them. MMF has now entered what's known as a 'Fast Loop'.
Once it's finished running those OnLoop events, it goes back up and runs 'em all again. And again. And again. And again, blindingly fast until it's done all of those OnLoop events 100 times. The reason it's so fast is because MMF is not stopping to redraw the screen.
Once the 100 loops have been performed, MMF goes back to the action which triggered the loop ("Start Loop 'blah' 100 times"). It now continues going through the events as normal. MMF has finished its fastloop, and is now finishing its Event Loop.
Once the eventloop is finished, it redraws the screen.
[size:11pt]Uses for Fastloops[/size]
Fastloops have the following advantages:
They're Fast
They Don't Redraw the Screen
The first advantage is obvious. Sometimes you need MMF to do something really really quickly, like loading a game save. Fastloops are so fast, you often don't need to create a Loading Screen at all!
The second advantage may not be so obvious, but is hugely cool. For example, you can loop through each enemy, checking how far they are from the player. If that enemy is within a certain distance, make him face the player.
If you did this with normal event loops, you'd see each enemy turn to face the player one after the other.
With fastloops, they all turn instantly.
[size:11pt]How to Use Fastloops[/size]
I may post some examples later, but for now, this description will have to do.
You can give each fastloop a name, to describe what it does. For example, if I'm scanning a list for some reason, I might name the loop "LIST SCAN".
You can also do several events PER loop.
Here's an example. We have two counters. When we press SPACE, we want to add 1 to the first counter and 5 to the second counter.
[events]
Using a Fastloop!
*User presses key "Spacebar"
-[obj_special]Start Loop "ADD" 100 times
*On Loop "ADD"
-Counter 1: Add 1
*On Loop "ADD"
-Counter 2: Add 5
[/events]
When you press space, the first counter will instantly say "100" and the second will instantly say "500". Because it didn't redraw the frame, you don't see the counter going up. It just instantly seems to jump.
'Fraid I can't do any actual MMF2 examples for you right now, but if someone else would like to, that'd be great. I hope this is good enough for now, if you have any other queries, just ask![]()



To back-up Dines explanation, here is a simple example comparing fastloop to event loop. The two methods are shown for adding all the numbers 0-999 into a listbox.
(Note: You dont really need a counter in the fastloop frame, you can access the loop index value and use that, but I left it to make the comparison clearer)
Small Example
It includes both points mentioned, first the speed difference and second the screen redraw, notice how the fast loop version doesnt show any numbers until the operation is complete.