Page 1 of 1

rnd() question

Posted: Wed Nov 05, 2014 6:26 pm
by mrRothchildsjr
Example:

varsleep = 0

10 d1 = int(RND * 6 + 1)

print d1

11 varsleep = varsleep + 1

pause(.1)

if varsleep = 10 then goto 13

12 goto 10

13 print "done!"


Hi! Why do I get ten 1s instead of pseudo-random dice rolls each time I execute?

Re: rnd() question

Posted: Wed Nov 05, 2014 6:34 pm
by Mr. Kibernetik
Because you need to use RND(x) function. Here you use just variable RND which is 0.

Re: rnd() question

Posted: Wed Nov 05, 2014 7:41 pm
by mrRothchildsjr
Thank you

Re: rnd() question

Posted: Wed Nov 05, 2014 7:43 pm
by mrRothchildsjr
Btw, the app is spectacular..Ty for making a great iOS programming language accessible..

Re: rnd() question

Posted: Thu Nov 06, 2014 1:21 am
by Mr. Kibernetik
Thank you very much for your comment!

Re: rnd() question

Posted: Thu Nov 06, 2014 6:47 pm
by Dalede
Do not use the INT function in you code. It does not do what you think. You need to use FLOOR

Dale