How would I do this?
I can't figure out if there is such a command in LSL as llRandom(min max) or anything... and I can't find anything on the wiki and searched the forums, and still couldn't really find anything.
Any help?
These forums are CLOSED. Please visit the new forums HERE
Generate a random number between 1-100? |
|
Okiphia Anatine
Okiphia Rayna
Join date: 22 Nov 2007
Posts: 454
|
01-07-2008 09:15
How would I do this?
I can't figure out if there is such a command in LSL as llRandom(min max) or anything... and I can't find anything on the wiki and searched the forums, and still couldn't really find anything. Any help? _____________________
In-world, I am Okiphia Rayna. This account is an alt, and is the only account I currently have with payment info on-file due to some account cracking that took place. This is a security measure at present, and I may return to the forums as Okiphia Rayna at a later date.
If you need to reach me, IM Okiphia Rayna, not Okiphia Anatine |
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
|
01-07-2008 09:24
It's http://wiki.secondlife.com/wiki/LlFrand
For 1-100, do something like (integer)(llFrand (99.0) + 1.0); |
Okiphia Anatine
Okiphia Rayna
Join date: 22 Nov 2007
Posts: 454
|
01-07-2008 09:26
It's http://wiki.secondlife.com/wiki/LlFrand For 1-100, do something like (integer)(llFrand (99.0) + 1.0); Yay thankies! Oh duhr.. I remember seeing Frand recently too..lol.. _____________________
In-world, I am Okiphia Rayna. This account is an alt, and is the only account I currently have with payment info on-file due to some account cracking that took place. This is a security measure at present, and I may return to the forums as Okiphia Rayna at a later date.
If you need to reach me, IM Okiphia Rayna, not Okiphia Anatine |
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
01-07-2008 23:36
integer rval = llFloor(llFrand(100)) + 1 // generate random number, round down, add 1. Range: 1-100
|
Debbie Trilling
Our Lady of Peenemünde
Join date: 17 Oct 2006
Posts: 434
|
01-08-2008 00:02
I like and often use this solution provided at : http://rpgstats.com/wiki/index.php?title=LlFrand
If you create a script where you need to generate several random integers, you might want to do yourself the favor of including this following simple function, which will allow you to get a random integer between x and y by simply calling RandInt(x, y) integer RandInt(integer lower, integer higher) { integer Range = higher - lower; integer Result = llFloor(llFrand(Range + 1)) + lower; return Result; } so, within the same script one can perform, for example, RandInt(1,100) or RandInt(1,10) or whatever and keep it all nice and neat and easy to read ![]() |