Getting aliases to give one of several randomized responses?

Posted by Silverwood on Tue 30 Nov 2010 05:07 PM — 4 posts, 16,913 views.

#0
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! =)
USA Global Moderator #1
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
Amended on Tue 30 Nov 2010 05:41 PM by Fiendish
Australia Forum Administrator #2
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).
Amended on Tue 30 Nov 2010 09:13 PM by Nick Gammon
#3
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!*