User Tag List

Results 1 to 4 of 4

Thread: Foreach Random

  1. #1
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Foreach Random

    I'm always told to use ForEach loops instead of fastloops for practically everything. Well I've come across a dilemma. I want the ForEach object to iterate through some objects randomly and never pick the same one twice until the pool is refilled. Is this possible?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    happygreenfrog's Avatar
    Join Date
    May 2011
    Location
    I.L.T.D.O.I.R (I.L.T.D.O.I.R's Location: The Dimension Of Infinite Recursion)
    Posts
    4,307
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I think I have an idea on how to do it, but you might need to explain in further detail first.

  3. #3
    Clicker Multimedia Fusion 2Android Export Module
    Corlen's Avatar
    Join Date
    Mar 2007
    Location
    Your House
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want the game to cycle randomly through all the provinces on the map once per game month where each one takes a turn. A month passes after all provinces have taken a turn. I was able to pull it off with foreach but to my dissatisfaction it cycled through all the provinces in the order in which they were created (going backwards from 30 to 1) and I need them to be selected randomly instead.

  4. #4
    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)
    You could try having a recursive for each loop for each object. This might make it random.

    For example;

    +Some initial conditions
    -Run loop "myfirstloop" for "myobject"

    +On "myfirstloop" for "myobject"
    +Flag 0 is off for "myobject"
    +Pick a random "myobject"

    -Turn Flag 0 on for "myobject"
    -Run loop "myfirstloop" for "myobject"


    This should effectively run through each object once and make it random at the same time.

Similar Threads

  1. Random Active Spawn in Random Location in Frame
    By Top_of_the_Temple in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 20th October 2016, 03:33 AM
  2. Make Random Pool not-so-random?
    By UltraHammer in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 4th April 2013, 02:53 PM
  3. BUG: Random is not random in Flash mode
    By oldkliker in forum SWF/Flash Export Module Version 2.0
    Replies: 1
    Last Post: 11th October 2011, 08:56 PM
  4. Random and MT Random strange behaviour
    By crusher in forum iOS Export Module Version 2.0
    Replies: 0
    Last Post: 8th October 2011, 01:32 PM
  5. Random Speed + Ypos at random times
    By Keehan in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 14th May 2011, 05:25 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
  •