User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11

Thread: Running loop in background while other events occur?

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export Module

    Join Date
    May 2013
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Running loop in background while other events occur?

    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?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    tompa's Avatar
    Join Date
    Nov 2011
    Location
    Uppsala, Sweden
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One way is to spread work over several rendered frames. Make one small iteration every gameloop.

  3. #3
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,541
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export Module

    Join Date
    May 2013
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    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).

  6. #6
    Clicker Fusion 2.5
    Del_Duio's Avatar
    Join Date
    Sep 2008
    Location
    Cygnus X-I
    Posts
    944
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    ^^ For you, anyway. You damned genius, you ^^

  7. #7
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,341
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    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.

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export Module

    Join Date
    May 2013
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    rubes's Avatar
    Join Date
    May 2011
    Posts
    366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  10. #10
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleSWF Export Module

    Join Date
    May 2013
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, rubes. With this kind of approach, couldn't I increase the "loop" speed by increasing the program's frame rate?

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Is running events through qualifiers faster then regular?
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th January 2013, 11:03 AM
  2. running events only once - smartest way
    By wizlore in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 25th September 2012, 12:38 PM
  3. Game not running in background
    By colej_uk in forum Android Export Module Version 2.0
    Replies: 2
    Last Post: 2nd April 2012, 12:17 PM
  4. Running a loop (Advance help needed probably)
    By Jase in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 6th July 2010, 05:18 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •