Multiple aliases matching same line

Posted by Cron0 on Sat 22 Oct 2005 12:20 PM — 4 posts, 26,621 views.

United Kingdom #0
I can do this with triggers but I can't seem to figure out how to do it with aliases. What I would like is to have two aliases with the same pattern but in different groups so I can enable one and disable the other depending on circumstance. When I try to add a second alias it tells me that 'this alias is already in the list of aliases' and won't let me do it.

I guess I could set a variable and have each alias check it and execute different commands depending on the value, but it seems more logical to use alias groups in the same way you would do it with triggers. Any ideas?
Australia Forum Administrator #1
Well, MUSHclient tries to be smart and stop you having multiple aliases that all match the same thing, as it could be confusing. However maybe that test should be discarded, since it doesn't allow for things like what you are trying to do.

As a workaround, you can get multiple aliases into your alias list in a couple of ways. One is to copy and paste using the Copy and Paste buttons. However once you have done that any attempt to edit the pasted alias (to make it do something different) will result in the error message again.

Another approach is to use ImportXML, which successfully imports duplicates. It is easy in Lua because you can have multi-line literals. For example:


ImportXML [[
<aliases>
  <alias
   match="test"
   enabled="y"
   sequence="100"
  >
  <send>blah</send>
  </alias>
</aliases>
]]


You can create the "template" for the alias by simply copying an existing one to the clipboard, and then amending it as required (eg. different send text).

Australia Forum Administrator #2
Another approach which will work, but is a bit of a kludge, is to do this.

Take your alias, and convert it to a regular expression if it isn't already (by clicking on the button). Then add a different comment to the regular expression for each one. This will make them "different" and will let you have multiples.

There is a button in the "edit alias" dialog box (labelled "->") that lets you enter a comment, and puts the cursor in the right place for you to customise it. Here is an example:


<aliases>
  <alias
   match="^test$(?#copy a)"
   enabled="y"
   regexp="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>blah</send>
  </alias>
  <alias
   match="^test$(?#copy b)"
   enabled="y"
   regexp="y"
   keep_evaluating="y"
   sequence="100"
  >
  <send>blah</send>
  </alias>
</aliases>



These both match the word "test" but have "copy a" and "copy b" as comments to make them look different.
United Kingdom #3
Thanks Nick, I think I will try it with the regexp comments. One other thing I found while testing this was that it only seems to be a problem with the send to as world, so one other workaround would be to send to script and just use world.send or whatever. I do think it is strange you cannot have multiple aliases in the same way as triggers though, particularly as there is the sequence setting for aliases too.