User Tag List

Results 1 to 9 of 9

Thread: How to set a variable randomly to -1 or 1, can't find choose function

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    MonDieu72's Avatar
    Join Date
    Dec 2013
    Posts
    93
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    How to set a variable randomly to -1 or 1, can't find choose function

    So I decided to once again try to make something with CF2.5 but keep getting stumped by what should be very easy to do.
    I have an active object and at start of frame I want to set one of its variables to randomly be -1 or 1 but I can't find a way to do this.
    Why is there no "choose(x1, x2, x3....) function?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleInstall Creator Pro
    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
    Oct 2007
    Location
    UK
    Posts
    306
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    You could try setting the variable to something like this: RRandom( - 1, 0 )

    Then, if necessary, set the variable to 1 if its random value = 0.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    MonDieu72's Avatar
    Join Date
    Dec 2013
    Posts
    93
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Caesar View Post
    You could try setting the variable to something like this: RRandom( - 1, 0 )

    Then, if necessary, set the variable to 1 if its random value = 0.
    That would not make it a 50/50 chance but rather 33/66 wich is not acceptable, thanks for answering though

  4. #4
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCUnicode Add-on

    Join Date
    Jan 2009
    Location
    FRANCE
    Posts
    158
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Hello,
    Just do Random(2)*2-1 and you should get either -1 or 1.

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export Module
    MonDieu72's Avatar
    Join Date
    Dec 2013
    Posts
    93
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Windlake View Post
    Hello,
    Just do Random(2)*2-1 and you should get either -1 or 1.
    Thank you

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleInstall Creator Pro
    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
    Oct 2007
    Location
    UK
    Posts
    306
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MonDieu72 View Post
    That would not make it a 50/50 chance but rather 33/66 wich is not acceptable, thanks for answering though
    RRandom( - 1, 0 ) would be a 50/50 chance. The result would give either -1 or 0. If it was RRandom( - 1, 1 ), then yes. It would be a 1 in 3 chance: -1,0,1.

    Windlakes solution is definitely better for what you need though.

  7. #7
    Clicker Fusion 2.5 (Steam)

    Join Date
    Nov 2016
    Posts
    40
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    RRandom(0, 1)
    Equal 0 -> Set to -1

  8. #8
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleiOS Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)
    elvisish's Avatar
    Join Date
    Oct 2014
    Posts
    761
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Windlake View Post
    Hello,
    Just do Random(2)*2-1 and you should get either -1 or 1.
    Thanks, is great for random direction setting!

  9. #9
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export Module

    Join Date
    Feb 2014
    Posts
    1,031
    Mentioned
    26 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Windlake View Post
    Just do Random(2)*2-1 and you should get either -1 or 1.
    very clever 1 line event

Similar Threads

  1. Where Is The Find Function Located?
    By DokieMaster in forum Fusion 2.5
    Replies: 2
    Last Post: 1st June 2016, 10:09 AM
  2. Import variable value to xLua function
    By Lazarus1988 in forum Fusion 2.5
    Replies: 8
    Last Post: 27th September 2015, 01:17 PM
  3. Randomly choose a counter for a number
    By OHMwake in forum Fusion 2.5
    Replies: 3
    Last Post: 25th January 2015, 11:07 AM
  4. Can't find function
    By Perry in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 12th December 2013, 11:23 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
  •