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
➜ VBscript
➜ Unusual alias question
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Omgbrady
(2 posts) Bio
|
| Date
| Mon 19 May 2008 05:20 PM (UTC) |
| Message
| Alright, so.. I play this RPI MUD called Armageddon, and I've found an extensive list of slang terms that my character would use.
However, since the list is so crazy long, there's no chance that I'll ever remember everything I want to.
So, here's my question. Does MUSHclient have the capability to replace single words in lines of text input by the user?
For instance, if i were to input the following..
Amos got caught with some stolen gear, and got executed. He tried to bribe the templar, but to no avail.
I'd want the client to send the following to the game.
Amos got caught with some ard gear, and got jammed. He tried to grease the bawler, but to no avail.
Is this possible?
Thanks in advance.
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Mon 19 May 2008 09:17 PM (UTC) Amended on Mon 19 May 2008 09:18 PM (UTC) by Nick Gammon
|
| Message
| Yes that is pretty easy with a bit of scripting for an alias. The alias below illustrates the idea, and you can just add words to the list in the same format. It uses Lua (I know you are in the VBscript section, but perhaps you could make the switch to Lua?). Failing that, you can make a plugin, where the plugin uses Lua but the rest of your stuff in is VBscript. That is really easy to do with the plugin wizard.
Anyway, here is the alias:
<aliases>
<alias
match="^(say |'|chat )(.*)$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>
replacements = {
stolen = "ard",
executed = "jammed",
bribe = "grease",
templar = "bawler",
--> add more words here
}
Send ("%1" .. string.gsub ("%2", "%a+", replacements))
</send>
</alias>
</aliases>
See http://mushclient.com/pasting for how to copy and paste that into the client.
Basically it uses a single string.gsub (global substitution) to replace every word found by the regular expression %a+ (one or more letters), from the list in the replacements table. Simply add more words to the table to expand it.
The way it is written the target words have to be pure letters (A-Z) and not include punctuation or numbers. You could change that if necessary.
The first part of the alias checks for the words "say ", "chat ", or a single quote. You can expand that as required.
eg.
match="^(say |'|chat |whisper |tell |shout )(.*)$"
|
- 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.
15,016 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top