Gammon Forum
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 (22,973 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 |
|
Posted by
| Omgbrady
(2 posts) bio
|
Date
| Reply #2 on Mon 19 May 2008 09:19 PM (UTC) |
Message
| Spectacular. Thanks! | 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.
10,654 views.
It is now over 60 days since the last post. This thread is closed.
  Refresh page
top
Quick links:
MUSHclient.
MUSHclient help.
Forum shortcuts.
Posting templates.
Lua modules.
Lua documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.