Setting a variable to a random number in a script call

Discussion in 'RGSSx Script Support' started by Zero0018, Feb 13, 2015.

Thread Status:
Not open for further replies.
  1. Zero0018

    Zero0018 Apprentice Member

    Messages:
    133
    Likes Received:
    1
    First Language:
    English
    $game_variables[13] == ?

    How?

    Set variable 13 == to random number between 1 and 3.
     
    #1
  2. seita

    seita Donn_M Veteran

    Messages:
    2,255
    Likes Received:
    611
    Location:
    California
    First Language:
    English
    Last edited by a moderator: Feb 13, 2015
    #2
  3. Yato

    Yato (aka Racheal) Veteran

    Messages:
    826
    Likes Received:
    345
    Location:
    Canada
    Code:
    $game_variables[13] = rand(3) + 1
     
    Last edited by a moderator: Feb 13, 2015
    #3
  4. Gothic Lolita

    Gothic Lolita YouTube Starlet Veteran

    Messages:
    1,132
    Likes Received:
    197
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    I know I shouldn't ask in topics I don't made, pleease excuse me for that. :'(
    But the first two things I understand, one is for the variable number, the second thing is in what way they should randomize. ;)
    But why do I need the +1 at the end of it? (\s/)
     
    #4
  5. Zero0018

    Zero0018 Apprentice Member

    Messages:
    133
    Likes Received:
    1
    First Language:
    English
    Thanks
     
    #5
  6. Engr. Adiktuzmiko

    Engr. Adiktuzmiko Chemical Engineer, Game Developer, Using BlinkBoy' Veteran

    Messages:
    14,640
    Likes Received:
    2,966
    Location:
    Philippines
    First Language:
    Tagalog
    rand(NUMBER) produces a number from 0 to (NUMBER - 1)... so in order to have a number from 1 to NUMBER, you need the +1
     
    Last edited by a moderator: Feb 13, 2015
    #6
    Gothic Lolita likes this.
  7. TheObermotz1

    TheObermotz1 Veteran Veteran

    Messages:
    34
    Likes Received:
    17
    First Language:
    German
    And what would one put into the script, if they wanted a random number out of a pool of seperate numbers (like 4, 6 and 12)?
     
    #7
  8. TheoAllen

    TheoAllen Self-proclaimed jack of all trades Veteran

    Messages:
    4,438
    Likes Received:
    5,029
    Location:
    Riftverse
    First Language:
    Indonesian
    Primarily Uses:
    RMVXA
    Code:
    $game_variables[x] = [1,3,5,7,9,0,11,31,41].shuffle[0]
     
    #8
  9. Kes

    Kes Global Moderators Global Mod

    Messages:
    20,926
    Likes Received:
    10,640
    First Language:
    English
    Primarily Uses:
    RMVXA
    #9
Thread Status:
Not open for further replies.

Share This Page