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.
Entire forum
➜ MUSHclient
➜ Tips and tricks
➜ Random alias
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Sparafucile
(9 posts) Bio
|
Date
| Wed 19 Oct 2005 12:16 AM (UTC) |
Message
| Hey guys. I have no scripting experience, and I need some help. I'm trying to do a random alias thing for a certain chat channel on the mud I play. Basically, every time I do 'bc (text)' I want it to do something like this:
Input: bc (text)
Output: {Buddy) [Alias 1] (text) OR
(Buddy) =Alias 3= (text) OR
(Buddy) ---Alias 2--- (text) OR... etc
So, every time I type in the channel, I want the script to pick a random alias to put a certain string before my text. I know it's asking alot to write a whole script out for me, but hey, I wouldn't know where to start. Or maybe at least give me the basics; I have -some- programming experience. Thanks! | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #1 on Wed 19 Oct 2005 08:26 AM (UTC) Amended on Wed 19 Oct 2005 08:27 AM (UTC) by Nick Gammon
|
Message
| This will do it, if you have Lua selected as your scripting language. Just copy and paste into the Alias list box (click the Paste button). You can add any number of names to the "names" table below. It randomly chooses one from the list.
<aliases>
<alias
match="bc *"
enabled="y"
send_to="12"
sequence="100"
>
<send>
do
local names =
{
"John",
"Nick",
"Peter",
"Margaret"
}
Send ("(Buddy) " ..
names [math.random (1, table.getn (names))] ..
" %1")
end
</send>
</alias>
</aliases>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Sparafucile
(9 posts) Bio
|
Date
| Reply #2 on Wed 19 Oct 2005 10:49 PM (UTC) |
Message
| Thanks, I really appreciate it. Unfortunately, I'm still having some trouble, this time calling the script. Here's what I did:
- Selected Lua as Scripting Language, checked the Enable Script box, copied the program in a .lua file, set the path to it in the Script File box.
- I assumed the name of the routine was aliases, so I put 'aliases' (without the '') in the Get Focus box. This could be my problem, but I don't think it is becase...
- when I click ok, I get an error message that looks like this. Error Number: 0, Event: Compile Error, Description: "[string "Script file"]:1: unexpected symbol near `<'", Called by: Immediate execution.
Sorry, I really know nothing about this, heh. Also, in the event that I do get it working, I make an alias 'bc *', and put what in the send box? the script filename? or the name of the subroutine, aliases? | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #3 on Thu 20 Oct 2005 02:07 AM (UTC) |
Message
| Copy that whole thing (<aliases> to </aliases> inclusive) and then go to the alias screen (thats the one you get to when you push the alias button, with the grid of aliases), and click the 'paste' button on that screen.
That's all you have to do! No mucking with script files. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Sparafucile
(9 posts) Bio
|
Date
| Reply #4 on Thu 20 Oct 2005 02:30 AM (UTC) |
Message
| Beautiful! thank you so much, both of you. Works like a charm! | Top |
|
Posted by
| Nick Gammon
Australia (23,120 posts) Bio
Forum Administrator |
Date
| Reply #5 on Thu 20 Oct 2005 06:47 AM (UTC) |
Message
| For future reference, the post Pasting triggers describes the general process. Although it refers to triggers the same idea applies to aliases. |
- 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.
21,620 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top