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?
rnd() question
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: rnd() question
Because you need to use RND(x) function. Here you use just variable RND which is 0.
-
- Posts: 6
- Joined: Wed Nov 05, 2014 6:22 pm
Re: rnd() question
Btw, the app is spectacular..Ty for making a great iOS programming language accessible..
- Mr. Kibernetik
- Site Admin
- Posts: 4786
- Joined: Mon Nov 19, 2012 10:16 pm
- My devices: iPhone, iPad, MacBook
- Location: Russia
- Flag:
Re: rnd() question
Thank you very much for your comment!
Re: rnd() question
Do not use the INT function in you code. It does not do what you think. You need to use FLOOR
Dale
Dale