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

 Related 
Contents
See also:
  Macros
  Editing Macros
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:
  #KEY
  Editing Macros
  0: For the Novice
Introduction to Macros [[cmud_%macro_intro]] 
Introduction to Macros

One of the first ways to make CMUD do more than just a dumb TELNET client is to assign commands to keys on your keyboard.

To assign a command to a key, press Control-K, or select Define Key from the Action menu. You will be prompted to press the key combination that you wish to assign a command to. Almost any key on the keyboard can be assigned a command, in combination with the Shift, ALT, and Ctrl keys. If you assign the macro to a key already used by CMUD (like Ctrl-C for Copy), then your macro will override the CMUD command, so be careful about this. You can control whether your macros override Windows commands (like Alt-F) in your Command Line Preferences. Also, note that CMUD automatically activates the NUMLOCK mode to allow you to assign macros to the keypad. If NUMLOCK is off, the keypad functions as the cursor keys. Since the cursor keys are used to edit the command buffer and recall from the command history, you should refrain from assigning macros to the arrow keys (although you can if you want).

Once you press the key you want to assign a command to (for example, the NUM8 key, the 8 key on the keypad) you will be prompted for the command. Enter the text you wish to be sent to the MUD when you press this key. For example, if you were assigning a command to the NUM8 key, you could enter the text north. Now, when you press the NUM8 key, the text north is sent to the MUD. Notice that when you press a macro key the text in the command entry field is selected, but is otherwise undisturbed. This is a very useful feature. For example, if there is a monster to the north that you want to hit quickly before it can hit you, you can enter kill monster in the command entry field, press the NUM8 key (to move north) quickly followed by pressing <Enter> to send the kill command to the MUD.

The Package Editor Macro editing screen looks like this:

For details on the properties, go to the Editing Macros topic.

Macro Chaining

If you want the text assigned to the macro key to be placed into the command line instead of being sent to the MUD, turn off the "Send to MUD" option in the Macro editor screen. To append the text of the macro key to the current contents of the command line, turn on the "Append to Command Line" option. Text will only be appended if the command line is not fully highlighted.

If you turn on the Daisy Chain option, then this macro can be used after other macro keys for a special effect called "Macro Chaining". When Daisy Chain is enabled, the macro text is appended to the command line if the command line ends in a space character. Then the whole command line is sent to the MUD. Otherwise, if the command line doesn't end in a space, the macro command is sent to the MUD normally.

The best way to understand how macro chaining works is to look at an example:

Define a macro key with the string "open " and turn off the "Send to MUD" option, but turn on the "Append" option. If you assigned this to the F8 key, then pressing F8 would put the text "open " in the command line (without sending it to the MUD).

Next, define a macro with a command of "north" and turn on the Daisy Chain option. Assign this macro to the NUM8 key on the keypad (actually, CMUD defines this macro for the number pad key automatically, and assigns directions like north, south, east, west to all of the keys on the number pad).

Now, when you press F8, the text "open " is placed in the command line. Now when you press NUM8, the command "north" is appended to the command line (since it ends with a space) and the command "open north" is sent to the MUD. However, if you just press NUM8 by itself with nothing on the command line, then the command "north" is just sent to the MUD.

Overriding default macros

By default, CMUD loads a package called "English Keypad" which assigns various direction commands to the keys on the numeric keypad. You can remove this package from your session, or load a different keypad package for a different language, if you are playing a non-English MUD.

However, if you just want to redefine these keys, you really do not need to delete or unload the defaults. Any macro that you define within your session window will override any macro assigned to the same key in different packages.

So, it's very easy to redefine the keypad keys. Simple press Ctrl-K as mentioned above, then press the key on the keypad you wish to define. The Package Editor will open and you should see KEY8 in the Key field. Now just enter the definition that you want for this key in the Script field and click the Save Changes button. Pressing the key on the keypad should now execute your custom script instead of the default script.
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net