Home   Help Search Login Register  

Author Topic: Random numbers  (Read 648 times)

0 Members and 1 Guest are viewing this topic.

skid

  • Guest
Random numbers
« on: 07 Dec 2002, 13:18:22 »
Does anyone know how to get just whole numbers when using the random number function?.
 
 If anyone clould help thank you.

seanver

  • Guest
Re:Random numbers
« Reply #1 on: 07 Dec 2002, 16:33:48 »
As far as i know you can't, but you can work with the numbers given just as if they were whole numbers. For example, we want to show a message if the number is 1 and another message if the number is two, working in a scirpt. If we use as condition that the number must be 1, we won't ever have the message since the number can be 1.321321 or 1.0032, for example. But we can set that if the number is less than or equal to 1, now we are actually working as if it was a whole number. so we can create a script like this:

_number = random 2

? (_number <= 1) : goto "MSG1"
? (_number > 1) : goto "MSG2"

#msg1

Hint "Helloooo its me!"

goto "end"

#msg2

Hint "Hello its me but with another message"

goto "end"

#end
exit

So this is the idea. Hope it helps
« Last Edit: 07 Dec 2002, 16:37:17 by SeAnVeR »

Offline Sentinel

  • Contributing Member
  • **
  • World is tough and I'm tougher!!
Re:Random numbers
« Reply #2 on: 07 Dec 2002, 18:15:01 »
There is mathematical fuction that gives what is left when you look how many times first number goes in second (don't know what the word is in English to this function 2/3). Anyway this is done with % number.

Example to clearify
5/2 is 2 and a half. When you do it like this 5 % 2 it gives number 1. Hope you understand.
Then when you have a random number eg. 3.58347. When you do this 3.58347 % 1 it gives 0.58347. When you substract this from original number you have number 3.

Hope you understand what I'm saying.

skid

  • Guest
Re:Random numbers
« Reply #3 on: 07 Dec 2002, 20:37:22 »
Thanks this Info has helped I think I can work around it now.