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
➜ Lua
➜ Random Number function.
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Shigs
(27 posts) Bio
|
| Date
| Mon 04 Feb 2008 04:42 PM (UTC) |
| Message
| | Sorry for all the silly questions, but I've checked the scriptfunction list and can't find a rand function, is there one and whats the syntax? | | Top |
|
| Posted by
| StuDraKi
Germany (17 posts) Bio
|
| Date
| Reply #1 on Mon 04 Feb 2008 04:50 PM (UTC) Amended on Mon 04 Feb 2008 04:51 PM (UTC) by StuDraKi
|
| Message
| I've looked for "rand" in the help function and found:
math.random () --> 0.30195013275552 (for example)
math.random (5) --> (a number from 1 to 5)
math.random (4, 8) --> (a number from 4 to 8)
And as it's alua function from the "module" math, it's not in the list of script functions (I assume). | | Top |
|
| Posted by
| Shigs
(27 posts) Bio
|
| Date
| Reply #2 on Mon 04 Feb 2008 04:53 PM (UTC) |
| Message
| Ok, it seems having the rand function dosen't help me at all,
What I actually wanted was a command to be inputted after a random number of seconds between 20-30 seconds, given the way timers work I can't do that or can I? | | Top |
|
| Posted by
| StuDraKi
Germany (17 posts) Bio
|
| Date
| Reply #3 on Mon 04 Feb 2008 05:01 PM (UTC) |
| Message
| By the way, there is a speed walk delay in the World Configuration->Input->Commands. but this is giving you a fixed delay.
But back to your question: it's possible, if I understand you correctly. How do you fire this? on an trigger you will send a fixed command with a random delay? Or you will put in "xx command" and after 20-30 seconds the command is send to the mud?
| | Top |
|
| Posted by
| Shigs
(27 posts) Bio
|
| Date
| Reply #4 on Mon 04 Feb 2008 07:12 PM (UTC) |
| Message
| | I was initaly thinking of setting a timer for 15 seconds and then having a delay of between 4-14 seconds to launch the command | | Top |
|
| Posted by
| Nick Gammon
Australia (23,169 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Mon 04 Feb 2008 08:29 PM (UTC) |
| Message
| As well as the MUSHclient functions you are advised to check the help for Lua functions, eg.
http://www.gammon.com.au/scripts/doc.php?general=lua_math
These are language-specific functions (or in some cases extensions I added for Lua) that do stuff like random numbers, sine, cosine, string formatting, and so on.
Quote:
What I actually wanted was a command to be inputted after a random number of seconds between 20-30 seconds, given the way timers work I can't do that or can I?
What is wrong with:
That generates a number between 20 and 30, randomly.
Thus you could do:
DoAfter (math.random (20, 30), "sigh")
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | 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.
29,032 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top