Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ Multiple aliases matching same line

Multiple aliases matching same line

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Cron0   United Kingdom  (11 posts)  Bio
Date Sat 22 Oct 2005 12:20 PM (UTC)
Message
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?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sat 22 Oct 2005 11:14 PM (UTC)
Message
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).


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #2 on Sat 22 Oct 2005 11:17 PM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Cron0   United Kingdom  (11 posts)  Bio
Date Reply #3 on Sat 22 Oct 2005 11:43 PM (UTC)
Message
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.
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.


25,760 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.