Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ DoAfter + random int

DoAfter + random int

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Wimbley   (10 posts)  Bio
Date Wed 01 Jul 2015 08:45 PM (UTC)
Message
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!
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 01 Jul 2015 09:11 PM (UTC)
Message
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).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Wimbley   (10 posts)  Bio
Date Reply #2 on Wed 01 Jul 2015 09:36 PM (UTC)
Message
Thank you! great advice, I will do that now.
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,805 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.