Unusual alias question

Posted by Omgbrady on Mon 19 May 2008 05:20 PM — 3 posts, 15,780 views.

#0
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.
Australia Forum Administrator #1
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 )(.*)$"


Amended on Mon 19 May 2008 09:18 PM by Nick Gammon
#2
Spectacular. Thanks!