DoAfter + random int

Posted by Wimbley on Wed 01 Jul 2015 08:45 PM — 3 posts, 14,064 views.

#0
I need a timer which works with a normal send of a fixed number or word, but I want it to randomize the number from 1 to 10.

DoAfter(math.random(50.6, 51.0)+1, Send (" " .. math.random(1,10))

The first part works by itself if I just use "" with anything between. How can I clean this up so it sends the number from 1 to 10 betwen those times? Thanks!
Australia Forum Administrator #1
The Send function is immediately evaluated, so you need to evaluate it afterwards, like this:


 DoAfterSpecial (math.random(50, 51)+1, 'Send (" " .. math.random(1,10))' , sendto.script)


BTW, math.random with two arguments takes integers, not floating point numbers. You are probably better off reworking that a bit (eg. add 50 instead of 1, and get a random number in the range 1 to 10, divide by 10, and add that).
#2
Thank you! great advice, I will do that now.