User Tag List

Results 1 to 6 of 6

Thread: How to get a random number based on specific ones?

  1. #1
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SergioAndre's Avatar
    Join Date
    Mar 2009
    Location
    Argentina
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to get a random number based on specific ones?

    Hi Guys!

    I need to get a random number based on previously specified numbers, something like "Random (1,3,5,12)".

    Does anyone know how to do it ?, I would like to do it directly from the expression calculator, if possible.

    Thanks in advance!

  2. #2
    Forum Moderator Fusion 2.5 MacFusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)Firefly 3D Module (Steam)
    NaitorStudios's Avatar
    Join Date
    May 2010
    Location
    Brazil
    Posts
    403
    Mentioned
    9 Post(s)
    Tagged
    0 Thread(s)
    You can do it with a list getting a random line from the amount available, or splitting a string with the numbers using the comma as token with string tokenizer then getting it with a random number for the index.
    Directly from expression calculator wouldn't work for one simple reason: numbers can have different amount of digits, you can't predict this.

  3. #3
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS 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)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    Killeen, TEXAS
    Posts
    1,055
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    the list is the easiest way; create list with each line representing one of the numbers you want to choose from(eg; 5 lines with a different result); do a normal random(1-5); and pick the line from the list. and VAL(the list$ number)

  4. #4
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SergioAndre's Avatar
    Join Date
    Mar 2009
    Location
    Argentina
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys! Doing it with a list is a good idea, but I don't like to use other objects than the basic ones if it is not really necessary, I always try to make things as simple and efficient as I can.

    Since it is not possible through the "expression calculator", I did it using the alterable values of an Active to store the already defined values, this way it can be done in a single line and it is very simple.

    I attach the .mfa in case someone has the same question and needs it.
    Attached files Attached files

  5. #5
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jan 2015
    Location
    Australia
    Posts
    211
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    The list is definitely the easiest way, but if you were really intent on not using any numbers, you could store your numbers in a global string, and then use Left$ and Right$ to snip out a part of that string and convert it to a number, like this


    It's not as elegant as using the list object though, but it can be done without using another object if you wanted

  6. #6
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    SergioAndre's Avatar
    Join Date
    Mar 2009
    Location
    Argentina
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by marbenx View Post
    The list is definitely the easiest way, but if you were really intent on not using any numbers, you could store your numbers in a global string, and then use Left$ and Right$ to snip out a part of that string and convert it to a number, like this


    It's not as elegant as using the list object though, but it can be done without using another object if you wanted
    @marbenx , that method is great!
    It's true that the list is the easiest way, but I always try not to use objects if it's not really necessary. The way you have done it seems great to me, just what I was looking for. Thank you!

Similar Threads

  1. Replies: 1
    Last Post: 28th May 2020, 08:02 PM
  2. Replies: 2
    Last Post: 23rd May 2017, 10:16 PM
  3. Replies: 21
    Last Post: 21st June 2015, 08:26 PM
  4. Getting a random number between a negative and positive number
    By D_Light in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 9th January 2013, 10:51 PM
  5. Returning number of objects under a specific condition
    By Ibis in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 14th November 2012, 01:23 AM

Posting Permissions

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