User Tag List

Results 1 to 9 of 9

Thread: Random number

  1. #1
    No Products Registered

    Join Date
    Aug 2008
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random number

    Hi, how can i create a random number in MMF2. Im trying to create a random gape of 0-3 seconds before a race starts but cant find anything in the search =(

  2. #2
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Random number

    The function is Random(Maximum value)- for a random number (0, 1, 2, 3) use Random(4).

  3. #3
    No Products Registered

    Join Date
    Feb 2007
    Location
    Sydney, Australia
    Posts
    1,654
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random number

    Like Jam(ie) said, use the "random( [color:#CC0000]<insert highest number here>[/color] )"

    So if you put random([color:#CC0000]5[/color]) it would pick any random number between 0 and 5.

    But if you want a number from 10 to 20, not 0 to 20 you need to do

    [color:#CC0000]10[/color] + random([color:#CC0000]20[/color])


  4. #4
    No Products Registered

    Join Date
    Mar 2007
    Location
    San Diego
    Posts
    280
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random number

    Quote Originally Posted by Dynamite
    But if you want a number from 10 to 20, not 0 to 20 you need to do

    [color:#CC0000]10[/color] + random([color:#CC0000]20[/color])

    shouldn't it be
    [color:#CC0000]10[/color] + random([color:#CC0000]10[/color])

  5. #5
    No Products Registered

    Join Date
    Aug 2008
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random number

    cheers. I am trying to get it to start between 0-3 seconds to hundreds of a seconds. so say liek 1.34 or 2.43s but im now having trouble with getting MMF to recognise when this happens. I have set two counters. One to Random(4) and one to random(100) and then comparing two global values checking seconds and hundreds values. I then tried creating another two counters to always keep value of timer seconds and timer hundreds (displays fine on screen) but sometimes MMF will start race ok and other times it will 'miss' and not start at all =( Thanks for the help!

  6. #6
    No Products Registered

    Join Date
    Dec 2006
    Posts
    1,332
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random number

    Quote Originally Posted by KetchupMaster
    Quote Originally Posted by Dynamite
    But if you want a number from 10 to 20, not 0 to 20 you need to do

    [color:#CC0000]10[/color] + random([color:#CC0000]20[/color])

    shouldn't it be
    [color:#CC0000]10[/color] + random([color:#CC0000]10[/color])
    For 10 to 20, it would actually be 10 + Random(11).

  7. #7
    No Products Registered

    Join Date
    Feb 2007
    Location
    Sydney, Australia
    Posts
    1,654
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random number

    Well I am still having trouble finding out what you want but Im guessing you want to choose a random number between 0 and 3 and the number represents seconds.

    What you do is change [color:#993399]Global Value A[/color], re-name it "[color:#993399]time[/color]".
    Also, change [color:#009900]Global Value B[/color], re-name it "[color:#009900]random_time[/color]"

    Do:
    [color:#3333FF]Every 1 mili second[/color] -- [color:#CC0000]Add 1 to [color:#993399]Global Value "time"[/color][/color].

    Now since you want it to start from the nearest mili second, instead of randomizing the numbers 0 to 3, you need to randomize them from 0 to 300.

    [color:#3333FF]Start of frame[/color] -- [color:#CC0000]Set [color:#009900]Global Value "random_time"[/color] to "Random(300)"
    [/color]

    Now you do:

    [color:#3333FF]Compare 2 general values, [color:#993399]Global value "time"[/color] is equal to [color:#009900]Global value "random_time"[/color][/color]
    -- Perform action

    Hope it helped! (:

  8. #8
    No Products Registered

    Join Date
    Jun 2006
    Location
    Land of raging rockets
    Posts
    1,231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random number

    Don't compare if the time is equal to the number. Check if it is equal or GREATER than.

    minutes >= random_minutes
    seconds >= random_seconds
    > do something great

  9. #9
    No Products Registered

    Join Date
    Aug 2008
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Random number

    Thanks very much!! =) Using greater than solved the problem of not always picking up the values. Genius =)

Similar Threads

  1. 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
  2. PARTICOLAR RANDOM number
    By daniele in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 21st October 2008, 10:54 AM
  3. Random Number Gen
    By mee in forum The Games Factory 2 - Technical Support
    Replies: 3
    Last Post: 7th February 2007, 09:06 PM
  4. Random Number Generator
    By bkfitww in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 9th December 2006, 11:30 PM
  5. Possible bug with random number generator
    By MJK in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 15th November 2006, 06:27 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
  •