User Tag List

Results 1 to 4 of 4

Thread: Generate random sign for integer

  1. #1
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2015
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Generate random sign for integer

    I'm generating a random number between 5 and 10:

    RRandom(5, 10)

    But I want to randomly assign it a positive or negative value. Basically I'm trying to generate a random number between -10 and 10 but excluding -4 to 4

  2. #2
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    679
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    randomly multiply the result by -1?

    If that doesn't work for you, populate a string with all of your numbers seperated by a delimiter, like this:

    "-10, -9, -8, -7, -6, -5, 5, 6, 7, 8, 9, 10"

    Then use the string tokenizer extension to split the string and retrieve a random element out of the 12: randomexample1.mfa

    EDIT: I forgot to, but instead of specifying Random(11), you can set it to Random(ElementCount("String Tokenizer")) to have it manually choose out of all elements.

  3. #3
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2015
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help casleziro

    I managed to solve it using this:

    RRandom(5,10) * Val(Left$("--", Random(2)) + "1")

    It randomly puts either one or two "minus" signs in front of the "1" making it positive or negative. Kind of weird solution but it works :P

  4. #4
    Clicker Fusion 2.5Fusion 2.5+ DLC
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    679
    Mentioned
    14 Post(s)
    Tagged
    0 Thread(s)
    Nice job. It's simpler than my solution at least.

Similar Threads

  1. Generate and display random numbers
    By sebaslunaquito in forum HTML5 Export Module 2.5
    Replies: 11
    Last Post: 12th May 2016, 07:45 PM
  2. Generate a random number
    By LemonyLime in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 11th May 2012, 03:37 PM
  3. Generate random number between -n and +n
    By Boba Fonts in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 30th January 2010, 08:21 PM
  4. generate random terrain (for chrilley)
    By Tisnart in forum File Archive
    Replies: 0
    Last Post: 2nd January 2010, 04:52 PM
  5. generate random number
    By Shawn in forum Multimedia Fusion 2 - Technical Support
    Replies: 7
    Last Post: 1st December 2009, 03:36 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
  •