[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  multiple aliases on one line

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

multiple aliases on one line

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Crimson_mordum   (4 posts)  [Biography] bio
Date Fri 24 Mar 2006 08:02 PM (UTC)  quote  ]
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,798 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 24 Mar 2006 10:05 PM (UTC)  quote  ]

Amended on Fri 24 Mar 2006 10:38 PM (UTC) by Nick Gammon

Message
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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Crimson_mordum   (4 posts)  [Biography] bio
Date Reply #2 on Fri 24 Mar 2006 11:28 PM (UTC)  quote  ]

Amended on Fri 24 Mar 2006 11:33 PM (UTC) by Crimson_mordum

Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (18,798 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 25 Mar 2006 01:20 AM (UTC)  quote  ]
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Stern   (1 post)  [Biography] bio
Date Reply #4 on Wed 29 Mar 2006 02:31 PM (UTC)  quote  ]
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (18,798 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Thu 30 Mar 2006 12:28 AM (UTC)  quote  ]
Message
Check "keep evaluating" for both triggers.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


1,301 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]