Setting a variable to a random number in a script call

$game_variables[13] == ?

How?

Set variable 13 == to random number between 1 and 3.
$game_variables[13] = rand(3)+1

== checks to see if the two values on both sides are the same

= sets the value on the left to that of the right

edit:

also may be better to ask these questions here:

http://forums.rpgmakerweb.com/index.php?/topic/150-rubyrgssx-questions-that-dont-deserve-their-own-thread
Code:
$game_variables[13] = rand(3) + 1
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/)
Thanks
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
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)?
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)?
Code:
$game_variables[x] = [1,3,5,7,9,0,11,31,41].shuffle[0]
Necro-post notice: TheObermotz1
The last post was well over 3 years ago.

If TheoAllen's answer is not sufficient for you, please post your query in this thread
http://forums.rpgmakerweb.com/index...-questions-that-dont-deserve-their-own-thread

Moderator note: Closing this.

Original thread: https://forums.rpgmakerweb.com/threads/setting-a-variable-to-a-random-number-in-a-script-call.36863/