-
I am doing an elementary school math game and I need the action scripting code for selecting random numbers.
I have used the code "variable" = random (10) for numbers
0-10, but I find that I don't need the 0. Please let me know how I can write the script that only selects numbers between 1-9. I have tried everything. Thanks so much.
-
dunno if this will help... but give it a go:
"variable" = random(10) + 1;
i believe since random(10) produces 0-9, adding the + 1 will make it 1-10.
if you don't want decimal numbers (i.e, 1.2345677) then try this:
"variable" = Math.round(random(10)+1);
I'm only a newbie so this was my best shot at it.
Someone please correct me if I am wrong or point out a better way to do it.
Thanks and good luck.
--Wyl
-
oops....for numbers 1-9 do this.
"variable" = random(9) + 1;
or
"variable" = Math.round(random(9) + 1);
--Wyl
-
Thanks so much for the tip. It will float the boat! Have a good week.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|