Register to post in forums, or Log in to your existing account
 

 Related 
Contents
See also:
  Aliases
  Editing Aliases
Scripting
  Introduction to Aliases
  Introduction to Macros
  Introduction to Variables
  Introduction to Classes
  Introduction to Triggers
  Introduction to Buttons
  Introduction to Multiplaying
  Introduction to Paths
  Introduction to Events
Related Links:
  Editing Aliases
  0: For the Novice
Introduction to Aliases [[cmud_%alias_intro]] 
Introduction to Aliases

Aliases are another way to simplify your life of MUD playing. Basically, aliases allow you to assign any command to a shortcut abbreviation.

The easiest way to create an alias is to type the command or words you want to make a shortcut for, then press Control-A, or select Make Alias from the Action menu. You will be prompted for the shortcut abbreviation you wish to assign the command to. For example, enter the text fill waterskin statue and press Control-A. Then enter fs and click Save changes and then close the editor window (or just press Enter to save and close the window). Now, whenever you enter fs in the command buffer, the string fill waterskin statue will be sent to the MUD.

Note that aliases are only translated if they are the first word in a command. In the example described above, if you entered the text say fs on the command line, the string say fs is sent to the MUD and fs is not translated.

Aliases Settings Editor



You can edit all of your aliases using the View/Aliases menu command, or by clicking the Aliases button in the main toolbar. This brings up the Package Editor in the alias edit mode. All of your aliases (like fs from the above example) are displayed in the list on the left. To edit an alias, just click on it and the details will be shown on the right side of the window. To define a new alias, click the New button and enter the name and commands for the alias. You can copy an alias by selecting it and using the Copy command in the Edit menu (or the right-click popup menu). Then select Paste from the Edit menu to make a copy. Multiple items can be copy and pasted. To delete an alias, select it and use the Delete command in the Edit menu (or the right-click menu).

This is an example of using the CMUD Package Editor. It has a list of your settings, just like Windows Explorer shows a list of your files and directories. The buttons on the filter toolbar on the left edge of the window allow you to select what kinds of settings you wish to view. For example, to view Aliases, click the Alias button. To view Triggers, click the Trigger button. To view more than one item at a time, hold down the Shift or Ctrl key as you click the button. You can also click the All button to display all settings.

The Package Editor is used to edit all kinds of things in CMUD, not just Aliases. To learn more, go to the Package Editor help topic. See the Editing Aliases topic for more information on the specific editor fields and options.

The ALIAS command

Another way to define an alias is using the #ALIAS command. Commands are typed entirely in the command input line at the bottom of the screen, but perform an action within CMUD and normally don't send any text to the MUD. Commands are provided for users of text-based MUD clients like TINTIN, and are similar in syntax. To create an alias with the ALIAS command, type

#ALIAS shortcut {command text}

The command text will then be assigned to the shortcut abbreviation that you supply. You can also list all aliases by just entering #ALIAS, or you can list the definition of a single alias using #ALIAS shortcut.

Aliases can also contain Arguments (also sometimes called Parameters). Arguments are the text following the shortcut. For example, if you enter fs foo bar, fs is the alias shortcut, foo is the first argument, bar is the second argument. Arguments are assigned to special numeric functions %1 through %99. In the previous case, %1 would contain foo, and %2 would contain bar. You can use these arguments in the alias itself.

For example, define the alias

#ALIAS k {kill %1}

Now when you enter k rabbit, the command kill rabbit is sent to the MUD.

Instead of using the cryptic %1 notation, you can use "named arguments" in CMUD. To rewrite the above example using the argument name of "target" instead of %1, you would type:

#ALIAS k($target) {kill $target}

The $ in front of the argument name indicates that this is really a Local Variable reference. Don't worry about that now. Just keep in mind that whenever you use a named argument, you always put a $ before the name.

Sometimes you might now know how many arguments are sent to the alias. Perhaps you want to send all of the text after the alias to the MUD. You can use the special syntax %-1 to send all arguments starting with the first (or %-2 to send all arguments starting with the second, etc). For example:

#ALIAS tz {tell Zugg %-1}

If you enter tz hello, how are you? then it will send tell Zugg hello, how are you? to the MUD. Instead of %-1, you can use the %params function if you'd like.

Using the same alias name as a MUD word

What do you think would happen if we created an alias like this:

#ALIAS kill {kill %1}

This actually causes an infinite alias loop! When you enter kill Zugg on the command line, it calls the "kill" alias, which then sends the "kill Zugg" command again and again and again.

To force CMUD to send a word to the MUD without running it as an alias, place the "escape" character ~ in front of the word. For example, the CORRECT EXAMPLE is this:

#ALIAS kill {~kill %1}

This will send the "kill Zugg" text to the MUD without the infinite loop.

zMUD Users: When using an alias in zMUD, any unused arguments would be appended to the text sent to the MUD automatically. This no longer happens in CMUD. If you want the arguments after the alias name to be sent to the MUD, you *must* add %-1 or %params to your alias definition.
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net