'Spread Value' is broken!
I have this one event with only one condition (always) and it has 2 actions, spread value '0' in 'ID' (alterable value A), and the second action is to start a loop. This isn't working. I made it put those object in the debugger. The first object's 'ID' is 1, and all the rest are 0.
Re: 'Spread Value' is broken!
Do it in two events, not one. Spreading a value and starting a loop in the same event is a *bad idea*.
Re: 'Spread Value' is broken!
especially if the loop comes before the spread event
Re: 'Spread Value' is broken!
raytrace:
doesn't matter, spread values messes up in the same event because of this:
"Spread values" is an action that is called upon all instances of the object you called it on. The problem is that the first instance of the object gets a value assigned immediately and then MMF2 runs the fastloop before giving ID's to the other objects. After the loop MMF2 will have forgotten which objects it was about to give an ID and then stops.
Events that looks like this:
+ Some conditions
--> Spread value 0 in val A
--> Start loop "blah"
Will be executed like this:
[Instance 1] Give value 0
Start loop "blah" //This is were MMF2 forgets the objects
[Instance ?] //huh?!? The objects are forgotten and MMF2 cannot give the rest of the objects an ID with 'spread values'
For info, Francois said this is design decision and not a bug... Even though most people would believe it is :P
Why start the first action and then put the rest of the instances in the end of an action queue? Why not just trigger them immediately in a loop before moving on? Would also save you the trouble of having a temporary list of actions. :)
Re: 'Spread Value' is broken!
It's because all the actions are executed in order for each object.
If you have two set value actions in one event for example, it'll do them alternately until they're applied to all objects. Conditions on the other hand are executed one at a time, looping the same condition for all objects of that type before going on to the next.
So if you have two objects of one type, two conditions and two actions in one event you'll get this happen:
Condition1 executes for Object 1
Condition1 executes for Object 2
Condition2 executes for Object 1
Condition2 executes for Object 2
Action1 executes for Object 1
Action2 executes for Object 1
Action1 executes for Object 2
Action2 executes for Object 2
With Spread value and a loop it ends up looking like this:
(Ignoring the "MMF forgetting the selection list across a loop" bug. This bug basically stops all actions in the same event as a "Start Loop" action affecting more than one object.)
Spread Value to Object 1
Start Loop for "Special Object"
(the special object is where the start loop action is. There's only 1 special object, so this action doesn't run again this event)
Spread Value to Object 2
(If there was two special objects, another loop would be run here. This could have happened with the old fast-loop extensions, but it's only possible to have one "special object".)
Basically, the problem is the order the actions are executed in. You should get the same problem with "Set Value" btw, so this shouldn't work correctly either (should only destroy one object):
[events]
*User clicks left button
-Set Alterable Value A of "Object 1" to 2
-Start Loop "Kill A" 1 times
*On Loop "Kill A"
+Alterable Value A of "Object 1" equals 2
-Destroy "Object 1"
[/events]
Re: 'Spread Value' is broken!
Oh ok. I will try it in 2 events. Thanks!
EDIT: Yay, it worked like a charm.
Re: 'Spread Value' is broken!
Just a quicky to see if I've understood why this is the case:
Suppose we have this event, and there are 5 enemies, and 5 detectors.
Start of Frame
- Spread 1 in ID of Enemy
- Spread 1 in ID of Detector
MMF selects all objects by default, and there are no conditions to narrow that selection down.
So what MMF *ACTUALLY* does is this:
Start of Frame
- Spread value in enemy 1
- Spread value in detector 1
- spread value in enemy 2
- Spread value in detector 2
- spread value in enemy 3
- Spread value in detector 3
- ...etc...
- spread value in enemy 5
- Spread value in detector 5
literally like a mini fastloop, it just keeps repeating until all selected objects have been handled.
However, if we were to include a fastloop, like this:
Start of Frame
- Spread 1 in ID of Enemy
- Spread 1 in ID of Detector
- Run Loop "My Loop" 6 times
Then MMF would do what it normally does - repeat EVERY action for every selected object. Since there are 5 enemies selected, the 'Run Loop 6 times' action would itself be run 5 times - giving us 30 loops. EG:
Start of Frame
- Spread value in enemy 1
- Spread value in detector 1
- RUN LOOP 6 TIMES
- spread value in enemy 2
- Spread value in detector 2
- RUN LOOP 6 TIMES
- spread value in enemy 3
- Spread value in detector 3
- RUN LOOP 6 TIMES
- ...etc...
- spread value in enemy 5
- Spread value in detector 5
- RUN LOOP 6 TIMES
So, to stop this happening, the first fast loop has to stop any other action-loops from happening, so that it doesn't get repeated.
But as a result, it stops the other actions from being applied to all the other objects.
That would explain it being a 'Design Decision'.
Re: 'Spread Value' is broken!
If an action is performed on an object and 5 objects are selected, it will do that action 5 times - but not *all* actions 5 times. Some actions it puts on the backburner and goes "I'll do that later".
Fast loops mess up object instance selection and backburner actions such as spread value. Put them in separate events.
Quote:
Originally Posted by Francois
This is not a bug, this is how the action routines are coded. I perform several loops of actions. The first exploration of the actions, calls all the actions, including the one shot actions like loops, sound etc., and the object oriented actions for the first object to be explored.
Then the next loops explores the remaining object oriented actions for the other objects, including the spread actions.
So if you want your spread action to be executed before, just duplicate the line of events.