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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Getting Started
. . -> [Subject]  Making aliases

Making aliases

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


Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Sun 05 Aug 2007 12:12 AM (UTC)

Amended on Sun 05 Aug 2007 12:15 AM (UTC) by Nick Gammon

Message

Another way of saving typing is to make an alias. Aliases match on something you type, and can be used to substitute something else, or do some other action (like call a script). First, let's replace having to type "task available" lots of times, by typing "ta" instead. First, we press Alt+Enter to open the world configuration, and click on "Aliases" on the left, and then "Add" to add a new one:

Aliases configuration

We only need to type in two things in this case. The alias "match" (which is "ta") and the alias "send text" (which is "task available"). Fill in these fields, and click OK:

Edit an alias

The alias now appears in the alias list. I can select it and click Edit to make changes later on, if I wish.

Aliases list

You can now type "ta" in the command window, and it will send "task available" to the MUD. The "ta" is not echoed, but "task available" is (in the output window). You can tweak that behaviour by editing the alias, and checking various other boxes (to echo the alias itself, check "Echo Alias", to not see what the alias is sending, check "Omit From Output").


Now let's make an alias that takes a variable parameter. For example, say when fighting we often need to kick our opponent. Rather than typing "kick kobold" all the time, it would be quicker to type "k kobold". The word "kobold" will vary, so we want to make that a "wildcard". Add a new alias, and this time match on "k *". That means "k" followed by a space, and then anything else:

Alias with wildcard

In the "send" field we put "kick" followed by %1. In the send box for aliases and triggers, %1 refers to the first wildcard (and %2 the second wildcard, and so on).


You might be wondering why you need to type "kobold" (or whatever the mob name is) each time you want to kick it. To save even more typing, we can make a targetting alias, that defines our current target. Then we can make a "kick" alias that kicks whoever the target is. First, the targetting alias:

Targetting alias

This lets you type "target kobold", and if you do, the first wildcard (%1) is sent to a variable (which is part of the MUSHclient world). In this case I have named the variable "target". I needed to fill in two extra fields, the "send to" combo-box has been changed to "Variable", and the variable name typed into the "Variable" field near the bottom of the alias. Now, having clicked OK to save the alias, I can then type "target kobold" in the command window. Nothing seems to happen, so let's check the variable configuration to see if the target was set. Hit Alt+Enter to open the world configuration, and check the Variables section:

Variables

It would be nice to get confirmation we have changed our target, so with slightly more work, we can do that. This time the alias will "send to script". Scripting is a powerful way of doing more complex things. The default is for Lua to be the scripting language, which is fine for this application. Simply change the "send" box to do a small script (two lines), and change the "send to" combo-box to read "Script":

Targetting alias

Now when I type "target kobold" I get a confirmation in the output window from the small script:

Targetting alias example

Finally, to tie this all together, we need a new alias, so that when I just type "k", it kicks the current target. So, we add a new alias, enter "k" in the match field (we don't need a wildcard this time), and then in the "send field" we put "kick @target". We also have to check "Expand Variables". Now when we type "k", MUSHclient will substitute whatever the contents of the "target" variable is, where it sees "@target":

Targetting alias example


- Nick Gammon

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

Posted by Nick Gammon   Australia  (22,982 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Fri 24 Jul 2009 01:41 AM (UTC)

Amended on Tue 26 Nov 2013 03:42 AM (UTC) by Nick Gammon

Message
This page has a link to a video showing a tutorial on how to make and use a targetting alias:

http://www.gammon.com.au/forum/?id=9616

- Nick Gammon

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

Posted by Zurishaddai   (3 posts)  [Biography] bio
Date Reply #2 on Thu 09 Aug 2012 02:55 AM (UTC)
Message
i no the thread is marked 2007 but would a rescue alias be pretty much the same concept of a targeting alias?
[Go to top] top

Posted by Spider_Curt   USA  (3 posts)  [Biography] bio
Date Reply #3 on Thu 09 Aug 2012 10:34 AM (UTC)
Message
Zurishaddai said:

i no the thread is marked 2007 but would a rescue alias be pretty much the same concept of a targeting alias?

Sure, I've applied this to many different situations. Just replace kick with whatever other action you wish to take.

You might find this thread of particular interest:
http://www.gammon.com.au/forum/?id=6602

good luck :)
[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.


26,972 views.

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

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at HostDash]