|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Oct 31, 2011 3:18 am
Macro IDs |
Can macros not have IDs? Any reason why?
|
|
|
|
hogarius Adept
Joined: 29 Jan 2003 Posts: 221 Location: islands.genesismuds.org
|
Posted: Mon Oct 31, 2011 4:16 am |
Can you make the macro call an alias, and use that ID?
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Oct 31, 2011 4:29 am |
I could, but that's not the point. Everything else can have an id, why not macros?
EDIT: Actually, it looks like several other things can't have ids either (aliases, variables, functions, paths, statusbars)... would be nice if everything could. |
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Oct 31, 2011 5:04 am |
Daern wrote: |
I could, but that's not the point. Everything else can have an id, why not macros?
EDIT: Actually, it looks like several other things can't have ids either (aliases, variables, functions, paths, statusbars)... would be nice if everything could. |
The identifier is the Name property of that setting. Triggers have a Pattern, which makes an ID (Name) property necessary to give quick access to them. The ID is actually the Name property or attribute. We don't have access to the actual ID as you can see by the below XML of this trigger. The actual id is 4, but the text I entered in the ID box was "test" which is the name attribute.
Code: |
<trigger name="test" priority="40" id="4">
<pattern>test</pattern>
</trigger> |
This alias has the same attributes.
Code: |
<alias name="test" id="8410">
<value>#show "TEST"</value>
</alias> |
Macros don't need an identifier. They are just key bindings. You should call a function or alias from the Macro instead of placing an entire script in it. If you want to enable or disable said macro, then just disable or enable the alias or function that those keys pressed execute, or write the script to check if a certain condition is true before proceeding and change that condition to false to disable it.
Code: |
<macro key="KEY5" id="5">
<value>#call @Test()</value>
</macro> |
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Oct 31, 2011 5:15 am |
Macros may not need an identifier, but it would be nice to have one. Why I bring this up is because I have a macro in a script that gets enabled and disabled in several places (using the key with the #T+/#T- commands). I sent it to a friend, but he already had a macro on that key, so he changed it, which broke everything. My first thought was to give it an ID, as I would do a trigger (or button, event, etc.) and change all the references to the key name to the new ID. That way it would be possible to change the key to whatever you want and it wouldn't affect anything. I ended up working around it by putting the macro in a class and enabling/disabling that, but it would be nice to have a unique identifier for macros that doesn't depend on what the actual key is.
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Oct 31, 2011 5:23 am |
Code: |
but it would be nice to have a unique identifier for macros that doesn't depend on what the actual key is. |
I understand what you are saying, but that's why you don't put the script in the macro itself but in an alias or function? Then you can use whatever key or macro you want to to call it. You're not enabling or disabling the key press but the script. Trying to do #T+ key5 makes no sense. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Oct 31, 2011 5:28 am |
Why does #T+ key5 make no sense? It works perfectly... And FYI, the macro does just call an alias, but I can't enable/disable the alias instead of the macro because a) the alias is called by other triggers elsewhere in the script, and more importantly b) if the alias is disabled, all of a sudden my macro would be spamming the alias name to the MUD, which is obviously not what I want. I want the macro to work sometimes and not work other times, and enabling/disabling the macro itself is the only way to do that.
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Oct 31, 2011 5:34 am |
So just set boolean variable and make the script in the macro to something like the following:
Code: |
#if (@bool) {aliasname} |
Instead of #T+ KEY# you would do bool = 1 or bool = 0. If bool is 0 then they can press that key all day long and nothing will happen. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Oct 31, 2011 5:38 am |
Sure, there's plenty of ways to work around it, my class thing is working just fine. I was just surprised that macros don't have ids, is all. Of course, I was under the impression that everything had ids at the time, having only ever had a need for them on triggers and events.
|
|
|
|
oldguy2 Wizard
Joined: 17 Jun 2006 Posts: 1201
|
Posted: Mon Oct 31, 2011 5:49 am |
Well if you actually disable the Macro, then wouldn't pressing the key send whatever that key is to the MUD anyway? At least if you hit Enter it will. Lets say the macro is KEY5. If I disable said macro, suddenly when I press KEY5 I am writing number 5 to the command line and possibly sending number 5 to the MUD instead of doing nothing, which is what I really want.
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Oct 31, 2011 5:54 am |
That's true, I hadn't considered macros on keys that are actual printable characters. I mainly just use function keys for my macros, besides the default keypad macros. I'll change it to your boolean variable idea, thanks for the suggestion
|
|
|
|
|
|