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
➜ Getting aliases to give one of several randomized responses?
Getting aliases to give one of several randomized responses?
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Silverwood
(12 posts) Bio
|
Date
| Tue 30 Nov 2010 05:07 PM (UTC) |
Message
| I figured this might be useful for people who want to do more than one thing with an alias with a random selection of responses.
For example, say I wanted to use "jig" as an alias.
Random response #1: emote Fred dances a merry jig.
Random response #2: emote Fred dances a jig around the room.
... and so on.
How might I do this? Thank so much for helping! =) | Top |
|
Posted by
| Fiendish
USA (2,535 posts) Bio
Global Moderator |
Date
| Reply #1 on Tue 30 Nov 2010 05:39 PM (UTC) Amended on Tue 30 Nov 2010 05:41 PM (UTC) by Fiendish
|
Message
| step 1) generate a random number
step 2) choose a response based on the random number.
Example:
the number = random between 1 and 20
if the number is less than 5 do one thing
else if the number is less than 10 do another thing
else if the number is less than 15 do another thing
else do the last thing
Another thing to do might be to set up a list of things you want to do that can be indexed with the number you generate.
if (in Lua), you have...
things = {first, second, third, fourth, fifth}
you could then do...
Send(things(math.random(1,5)))
or something like that |
https://github.com/fiendish/aardwolfclientpackage | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #2 on Tue 30 Nov 2010 08:41 PM (UTC) Amended on Tue 30 Nov 2010 09:13 PM (UTC) by Nick Gammon
|
Message
|
Fiendish said:
things = {first, second, third, fourth, fifth}
you could then do...
Send(things(math.random(1,5)))
Indeed. And to allow for the table getting larger:
things = {"first", "second", "third", "fourth", "fifth"}
Send (things [math.random (1, #things)])
This is because #things is the number of items in "things".
(Corrected to use square brackets to index into the table). |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Silverwood
(12 posts) Bio
|
Date
| Reply #3 on Tue 30 Nov 2010 10:14 PM (UTC) Amended on Tue 30 Nov 2010 10:17 PM (UTC) by Silverwood
|
Message
| This could all be done by adding an alias and getting it to send the response you gave to "script," yes?
*Edit: Tested it out; yup, it works. Thanks again for helping!* | 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.
13,180 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top