Programmatically editing macros

Posted by Krenath on Tue 18 Jun 2002 03:10 PM — 5 posts, 22,724 views.

USA #0
Just now I found myself needing to write some code that added/edited/deleted macros from within a script, but I was surprised to discover that there are no World.AddMacro and World.DeleteMacro commands. Nor do the GetInfo and GetOption functions seem to provide an interface to interacting with macros.

Does a method of editing macros exist?

I've noticed that plugins don't allow for macros (probably due to the limited number of available macro keys and the high probablility of collisions), so I'd planned on writing a plugin that would dynamically configure the macro keys in order to not only create them, but to manage what they accomplish as conditions and locations in the game change.

Oh, does the <macro> XML tag support the script parameter? I think I'll go test for that...
USA #1
Bah.

(1) Even if macros are set up within the world file to call scripts (by setting the send text to start with a /), they cannot access plugin scripts directly.

(2) Macros, in the XML file don't support the script tag

Eventually, I'd like to see macros expanded to the point where:
a. they're fully editable from scripts
b. they natively support scripting as triggers, timers, and aliases do.
c. they're supported by plugins
d. any key combination at all can become a macro, not just the F-keys and numeric keypad
e. MUSHclient features can be assigned to macros,overriding default menu hotkeys, allowing the user to customize the keypresses he uses to access MUSHclient menu items

I use HomeSite 5.0 for development at work, and it's spoiled me with its scriptability and customizability. :) The above list of features is, basically, taken from what HomeSite can do.
USA #2
I'm creating a workaround. Yay

Basically, I'll write a script for the world that intercepts macro keypresses, then checks each loaded plugin to see if it has a routine for handling that macro keypress and, if so, calls it with World.CallPlugin.

This would handle macro 'collisions' by the confusing but simple method of calling the macro script for all plugins that support it
Australia Forum Administrator #3
Quote:

Does a method of editing macros exist?


No yet. The macro handling is intended to be replaced by a more generic "keyboard mapping" feature, yet to be implemented. Then, perhaps, programmatic access could be added.
USA #4
Krenath-
-I can easily set my macros to different things indirectly by using aliases..


Steps:
    1. Have F9 send something like "Macro_F9+++"
    2. Have and alias match "Macro_F9+++" and send whatever you want, in the label section, type "MacroF9" or something
    3. Have another alias to change F9, like "CF9 *", in the label part type "ChangeF9" and in the script part "ChanAliF9"
    4. Add the following to the end of your script..



sub ChanAliF9 (sName, sLine)
  world.deletealias "MacroF9"
  world.addalias "MacroF9", "Macro_F9+++"
end sub