Working in MMF2, and having a problem with some code centred around fastloops. I'm wondering, is there a limited number of nested fastloops you can have? Like:
On Loop1
-Start Loop2
On Loop2
-Start Loop3
On Loop3
-Start Loop4
...etc...
Does anyone know if there is any maximum to this? And if so, what is the behaviour if one exceeds it?
n/a
Assault Andy Administrator
I make other people create vaporware
Registered 29/07/2002
Points 5686
14th February, 2007 at 02:27:07 -
I don't assume that there would be a limit, I have never encountered any problems. Why not just start a test for yourself? Also, what is your exact problem, we may be able to suggest an easier method of doing it.
Ah its cool, I found the cause of the problem. It's something to do with the Overlay Object. I'll do my best to explain what I'm trying to do with the code.
I have a list of filenames (fileList). The code iterates through this list, reading each filename and passing it to the Binary Object to load that file.
Inside these files are a couple of list files for the List Object, and a sequence of long-image file pairs, ie:
[long "x"][x number of bytes which make up the image file][next long "y"]...etc...
The code extracts the lists from this binary, and loads them into their respective List objects. So all thats left in the binary is the sequence on long/image pairs.
The code knows how many images there are in the file, as it is described in one of the lists it extracted. The code begins iterating through these images, and for each image performs the following:
- Extracts image to disk
- Creates a new Overlay Object
- Loads image on disk into Overlay Object
The goal is to have an overlay for each image that was in the binary, containing a respective image. However, what happens is only 1 image in 1 overlay will ever load. No other overlays will ever load images. Additionally, that Overlay object which DID load an image, will not be able to load a new image over the top. It's like the Overlay extension just locks or something...
There are a few footangles in the current overlay redux. One for example is that you cannot load the same picture twice behind each other. You have to load a dummy file with another name first.
For your problems here it's hard to say what exactly makes trouble without having a look at the source. Possible that something overrides each other ...
I imagine the only limit on nested fastloops (or even a single big loop, since they're executed practically the same way) would be the point where it takes more time to complete the series than MMF's refresh rate, which would probably just result in slowdown. Presumably the exact point would be different depending on your machine.
I have a question about fastloops, as I never do them.
To equate it to something I understand in VB (a FOR.. NEXT loop), is there a "NEXT X" part of the loop in MMF? Or is it the "on loop" command that does it?
I should really learn fastloops, blah.
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
After reading back over what I wrote, here's a better definition of the error:
An Overlay object will not load an image from file unless there exists no other instances of the Overlay object which have already loaded an image.
Very frustrating! So in a simple example, if you have 1 overlay object and load an image into it, then try to load another image into it [with the same file name], it won't work. You have to destroy the overlay and create a new one [or as you suggest, Tiles, load in a dummy file between them].
Del Duio, I'm sure theres at least a half dozen articles written on DC and elsewhere that explain fastloops, but I will try to equate it to VB code [as best I remember it]:
Events:
1. Start of Frame
- Start Loop "monkey" for 5 loops
2. On Loop "monkey"
- add 1 to counter
VB [or thereabouts]:
Call monkey(5)
Sub monkey(integer loops)
-for i = 0 to loops //[or maybe its loops-1...too tired to think it out right now]
--counter = counter + 1
-next i
End Sub
Hope that clears things up for you. A fast loop call is like jumping out of the event into the fastloop event and looping for however many times you told it to, then jumping back into the event which started the loop to the action immediately after the "start loop" action.
Edited by the Author.
Edited by the Author.
n/a
DaVince This fool just HAD to have a custom rating
Registered 04/09/2004
Points 7998
14th February, 2007 at 12:44:11 -
Try this:
- Start of frame: start loop "a" 1 time.
- on loop "a": start loop "b" 10 times.
- on loop "b": start loop "a" 10 times.
Del Duio: The equivalent of "NEXT X" occurs when there are no more "On loop x" events in the order of the event list. You can prematurely advance it by using "Set loop index", too.