This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.7
PTR
10.2.6
Beta
Macro to insert a name into another macro
Post Reply
Return to board index
Post by
754752
This post was from a user who has deleted their account.
Post by
HighFive
Just use the focus - it's the best solution to this.
If you're really concerned about the real-estate the frame is taking, you can set up a script to hide it.
This will do what you want:
/use Spell Here
/run if IsAltKeyDown() then EditMacro("bluh", nil, nil, GetMacroBody("bluh"):gsub("@]*", "@"..GetUnitName("target"), 1)) end
Replace "Spell Here" with the spell you wish to cast. Name the macro "bluh" or replace "bluh"s with the name you prefer. Hold down alt to set and don't to not set.
If the macro you wish to utilize this with is more sophisticated, post it.
edit: I just remembered, self-modifying macros must follow a certain rule due to the way scripts (scripts in macros?) are executed. The in the modified body of the macro, the closing parenthesis of the EditMacro call, must be in the same index, in which it was in the original (that is where the interpreter picks up after EditMacro).
A simple solution is padding with whitespace. What was the maximum player name length?
edit2: It is 12. This should do the trick:
/use Spell Here
/run if IsAltKeyDown() then EditMacro("bluh", nil, nil, GetMacroBody("bluh"):gsub("@]*", format("@%-12s", GetUnitName("target")), 1)) end
Note: If you use it on a mob or anything with a name longer than 12 characters, it will eviscerate itself.
Post by
22686
This post was from a user who has deleted their account.
Post by
HighFive
That may be true, if gsub can iterate backwards, or skip a number of tests.
edit: Oh well, here is a hack:
/run if IsAltKeyDown() then EditMacro("bluh", nil, nil, GetMacroBody("bluh"):gsub("(@]*", format("%s@%s", ",", GetUnitName("target")))) end
/use Spell Here
Post by
22686
This post was from a user who has deleted their account.
Post by
754752
This post was from a user who has deleted their account.
Post by
HighFive
...
:P
Self-modifying macros are fun and all, but they are way too complicated for their worth. You're much better off wrapping the modifying part in a function.
I thoroughly enjoy macro-modifying scripts though. Thankfully EditMacro is not protected and does not require a hardware event.
Post by
Ketho
You might be interested in
MTarget
This editmacro gsubbing looks fun though lol
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.