Jump to content
Sign in to follow this  
Tom Gore

Random x command

Recommended Posts

Here's a very simple, but important question:

Does the possible range of random X include X or not?

For example, can I get 10 from random 10 or is the largest possible returned value 9.999... ?

Could be researched by

#loop

_x = random 1

? _x != 1 : goto "loop"

hint "Found 1!"

exit

and letting it run for a while but it might take a lot of time to be sure (unless 1 was found, of course).

Suma? Anyone?

Share this post


Link to post
Share on other sites

Its a random number to _x so I dont think 1 or 10 is in it...

Share this post


Link to post
Share on other sites

That's what I would suppose aswell. It would be a standard random function then but as we have all noticed a few times, OFP scripting language isn't always that standard wink.gif

Share this post


Link to post
Share on other sites

random 1 (as far as i know) creates a value from

0.000000 to 0.999999

If you transpose those random's from real numbers to whole

numbers: _rnd = random 5

_rnd = _rnd - (_rnd mod 1)

the result would be a number from 0 to 4

0,1,2,3,4 (5 random values)

btw - it's not only ofp scripting which is different to some

programmer languages (there are even differences between

programmer languages) - but the point here is, you have

to accept the value 0 also as a value.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×