User Tag List

Results 1 to 10 of 10

Thread: How to 'stop' a ForEach loop?

  1. #1
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to 'stop' a ForEach loop?

    Hi
    How do i stop a ForEach loop?
    All i can see is a 'Pause' and 'Set Itteration' function.

    Is 'Pause' the same as stop loop, as far as the ForEach Object is concerned?

  2. #2
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    bump

    I have the same question. Someone can answer it?

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleSWF Export Module
    Skyhunter's Avatar
    Join Date
    Jan 2007
    Location
    Croatia
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, use the pause, it will stop the foreach loop, the action must be used in the foreach loop to actually stop it.

  4. #4
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. A follow up question. how can I skip foreach loops for an object, to reduce the cost of foreach calculations?

    + foreach NPC
    + is NPC (string A) = Busy
    - skip foreach loop for this object and go to the next NPC

    + foreach NPC
    + is NPC (string A) = Idle
    - do heavy calculations

  5. #5
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)
    King_Cool's Avatar
    Join Date
    Aug 2008
    Posts
    2,335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    + foreach NPC
    + is NPC (string A) = Busy
    - Set ForEach itteration to 'ForEach current itteration +1'

  6. #6
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I was afraid to use this method, because I thought it will just change the itteration NR. without restarting the whole loop for the next object.

  7. #7
    Forum Moderator Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export ModuleXNA Export Module
    ProdigyX's Avatar
    Join Date
    Jan 2011
    Posts
    1,197
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Morbus Crohn View Post
    Thanks. A follow up question. how can I skip foreach loops for an object, to reduce the cost of foreach calculations?

    + foreach NPC
    + is NPC (string A) = Busy
    - skip foreach loop for this object and go to the next NPC

    + foreach NPC
    + is NPC (string A) = Idle
    - do heavy calculations
    Just only have actions when the string = Idle. If the string has to = Idle, then if the event won't run when its Busy now will it?

  8. #8
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ProdigyX View Post
    Just only have actions when the string = Idle. If the string has to = Idle, then if the event won't run when its Busy now will it?
    Not sure if I know what you mean :-)

    I have 20 NPCs and some are idle and some are busy. So I need to test every NPC and if they are Idle I need to do further calculations.

  9. #9
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleSWF Export Module
    Konidias's Avatar
    Join Date
    Aug 2009
    Posts
    1,546
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    You don't need to cycle through all of the objects...

    You can just do this:

    NPC (string A) = Idle
    - do foreach loop for object

    This isolates only the objects that already have the string equal to Idle, and runs a loop through those objects only.

    edit: What ProdigyX is saying is that you don't need to check if the string is equal to Busy because it doesn't matter... It's not going to perform all the heavy calculations unless the string is equal to Idle in the first place. So it "skips" all that stuff regardless.

  10. #10
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Konidias View Post
    You don't need to cycle through all of the objects...

    You can just do this:

    NPC (string A) = Idle
    - do foreach loop for object

    This isolates only the objects that already have the string equal to Idle, and runs a loop through those objects only.

    edit: What ProdigyX is saying is that you don't need to check if the string is equal to Busy because it doesn't matter... It's not going to perform all the heavy calculations unless the string is equal to Idle in the first place. So it "skips" all that stuff regardless.
    Ok thank you Konidias.

    Just for understanding: If you write NPC (string A) = Idle, is mmf doing an "internal foreach loop" by checking all NPCs String A and then selecting all Idle NPCs for the following foreach loop? Is this faster then doing it manually with a foreach loop?
    I am still confused, which conditions do an "internal foreach loop" and which not.

Similar Threads

  1. ForEach loop question
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 17th July 2014, 12:05 AM
  2. ForEach loop for Object problem
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 11th April 2013, 12:00 AM
  3. [CRASH] ForEach loop with Groups/Qualifiers (256.31)
    By MJK in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 13th March 2013, 05:42 PM
  4. Want to do same loop with ForEach
    By Outcast in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 15th April 2012, 10:48 PM
  5. Game loop: ForEach or FastLoop?
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 20th December 2011, 01:49 PM

Posting Permissions

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