Setting a variable to a random number in a script call

Status
Not open for further replies.

Zero0018

Apprentice
Member
Joined
Dec 24, 2014
Messages
133
Reaction score
1
First Language
English
Primarily Uses
$game_variables[13] == ?

How?

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

Yato

(aka Racheal)
Veteran
Joined
Mar 17, 2012
Messages
825
Reaction score
346
Primarily Uses
Code:
$game_variables[13] = rand(3) + 1
 
Last edited by a moderator:

Gothic Lolita

YouTube Starlet
Veteran
Joined
Oct 21, 2014
Messages
1,132
Reaction score
197
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/)
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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:

TheObermotz1

Veteran
Veteran
Joined
Mar 5, 2014
Messages
34
Reaction score
17
First Language
German
Primarily Uses
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)?
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top