|
2 registered members (OptimusPrime, AndrewAMD),
14,580
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Random Number Generation and basic script structure
[Re: Icarni]
#320061
04/19/10 15:10
04/19/10 15:10
|
Joined: Aug 2003
Posts: 7,440 Red Dwarf
Michael_Schwarz
Senior Expert
|
Senior Expert
Joined: Aug 2003
Posts: 7,440
Red Dwarf
|
integer(random(256)); will give you a number from 0 to 256, random(256); will give you a number from 0.001 to 256.000
the structure you use if up to you and how you can work with best, the only thing you have to be careful of is that things are DEFINED BEFORE THEY ARE USED.
for example:
function add(i) { a = a+i; }
var a = 0;
is bad
var a = 0;
function add(i) { a = a+i; }
is good
"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
|
|
|
Re: Random Number Generation and basic script structure
[Re: Icarni]
#320063
04/19/10 15:11
04/19/10 15:11
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Firstly, re-check the manual a bit. random(256); will give you a number between 0.000000 and 255.999999 integer(random(256)); will give you a random integer between 0 and 255 so you want integer(random(256)+1); to get a random integer between 1 and 256. or clamp(random(256)+1,1,256); to get a random number between 1.000000 and 256.000000.
Secondly, dont change things around, it is FAR more trouble than it is worth.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Random Number Generation and basic script structure
[Re: Icarni]
#320074
04/19/10 16:20
04/19/10 16:20
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
no probs dude... and welcome aboard.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|
|
|