The Daily Click ::. Forums ::. Klik Coding Help ::. Fastloop Weirdness
 

Post Reply  Post Oekaki 
 

Posted By Message

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
7th January, 2009 at 23:56:52 -

I'm having some trouble understanding exactly how MMF2 handles duplicates during fastloops.
If anyone could shed some light on the matter, I'd appreciate it


Example
I have 4 duplicates of a counter object in a frame, and the following events;

* Start of frame
-> Set counter to Random(10)
-> Start fastloop "Test", 5 times

* On loop "Test"
-> Add 1 to counter


Personally, I'd have expected all four counters to show random numbers between 5 and 14.

What I actually get, is three of the counters showing "5", and the other counter showing a random number between 0 and 9.

What is going on?!


btw: My actual problem is probably caused by something else to do with fastloops going wrong, but I came across this when trying to make an example.

 
n/a

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
8th January, 2009 at 00:08:15 -

just wait a second. pixeltheif will be here shortly

 
n/a

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
8th January, 2009 at 01:19:04 -

The object scope sometimes gets messed up if you do an action on an object BEFORE starting a fast loop inside event code. As a rule of thumb, never interact with an object in the same line you execute a fast loop or function or whatever; instead of doing:

* Start of frame
-> Set counter to Random(10)
-> Start fastloop "Test", 5 times

* On loop "Test"
-> Add 1 to counter

Do this:


* Start of frame
-> Set counter to Random(10)

* Start of frame
-> Start fastloop "Test", 5 times

* On loop "Test"
-> Add 1 to counter

Works perfectly! Don't ask my why its messed up, all I know is it is :X But it also applies to active objects, etc etc


 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
8th January, 2009 at 01:35:32 -

Ok, thanks - think I've heard that before, now that you mention it

I managed to fix the other problem I was having, which I'd thought might be to do with fastloops (it wasnt).

Here's another problem (last one, promise)...

http://cid-b1e7ee094271bbda.skydrive.live.com/self.aspx/Public/LoSeg3.mfa

It works perfectly as it is.
I'm aware that it's not super-efficient, but that's not the problem.
I've tried adding an event to always add 1 to the enemy objects "CurrentHeading".
For some reason though, doing that always stops everything else working after about 5-10 seconds - it doesn't crash or anything, it just doesn't work anymore.

I don't have any timer based events, and it's not related to the object limit.

What else might be the problem?

 
n/a
   

Post Reply



 



Advertisement

Worth A Click