multiple aliases on one line

Posted by Crimson_mordum on Fri 24 Mar 2006 08:02 PM — 6 posts, 23,079 views.

#0
i am trying to set up an alias to color certain words.. however, at the moment, i canot ge tit to color more then a single thing on a line... as an example,
*kuvoc* sends %1&09K&00&01u&16v&00&01o&09c&16%2
*solbet* sends %1&00&12S&00&04o&00&03l&00&00&11b&00&12e&00&04t&00&16%2


but if i have both words on the same line, i can only get it to color one of them. I have tried fixing it, but it has yet to work.
Australia Forum Administrator #1
You need to do the replacements in a single alias. You can set "keep evaluating" but that would result in multiple sends. Using a bit of Lua scripting you can achieve that. I assume the line itself can be identified in some way (eg. chat xxx). This example assumes the line starts with "chat" but you can change that to whatever it is. Then inside the script we do a lookup of the words we want to do the replacement on. To expand the replacements, simply add to the table in the format shown.


<aliases>
  <alias
   match="chat *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

replacements = { 
   ["*kuvoc*"] = "&amp;09K&amp;00&amp;01u&amp;16v&amp;00&amp;01o&amp;09c&amp;16",
   ["*solbet*"] = "&amp;00&amp;12S&amp;00&amp;04o&amp;00&amp;03l&amp;00&amp;00&amp;11b&amp;00&amp;12e&amp;00&amp;04t&amp;00&amp;16",
   }
   
Send ("chat " .. string.gsub ("%1", "%%*%%a+%%*", 
  function (str) return replacements [str] or str end ))


</send>
  </alias>
</aliases>


I assumed the asterisks were part of it, if not use this:


<aliases>
  <alias
   match="chat *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

replacements = { 
   kuvoc = "&amp;09K&amp;00&amp;01u&amp;16v&amp;00&amp;01o&amp;09c&amp;16",
   solbet = "&amp;00&amp;12S&amp;00&amp;04o&amp;00&amp;03l&amp;00&amp;00&amp;11b&amp;00&amp;12e&amp;00&amp;04t&amp;00&amp;16",
   }
   
Send ("chat " .. string.gsub ("%1", "%%a+", 
  function (str) return replacements [str] or str end))


</send>
  </alias>
</aliases>




Don't be put off by all the &amp; above - that is just part of the way the & symbol is represented in the XML code. Once you copy and paste it into your alias list, the replacement text will look like how you had it.

Amended on Fri 24 Mar 2006 10:38 PM by Nick Gammon
#2
downside, i know nothing about using the scripts >.<.. the asterisks are the default variable characters... thus on the return, i had %1 and %2 to match text before and after
Amended on Fri 24 Mar 2006 11:33 PM by Crimson_mordum
Australia Forum Administrator #3
You don't really need to know scripting. Copy that second example I gave and paste into your alias list. See this post for how that works:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4777

That refers to triggers, but aliases are the same technique.

Then enable scripting (world configuration, scripting tab), and make sure the language is set to Lua.

Then the alias should just work, amending it slightly if necessary to change "chat" to whatever sort of line you are matching on. Then add more words to the list following the format in the alias.
#4
I am very unexperienced with MUSHclient but I have been trying to make it colour different words on the same line. Is there an option or something I can tick so that it allows other triggers to be put in the same line? for example I have one trigger that colours "bodyguard" to orange, and another that triggers "samurai" to orange. But if there is a line that says

"A bodyguard and a samurai are standing here"

the only one that gets coloured is the one thats higher up in my triggers list.
Australia Forum Administrator #5
Check "keep evaluating" for both triggers.