This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.5
PTR
10.2.6
Another puzzle for the experienced Lua Wizards...
Post Reply
Return to board index
Post by
RedwoodElf
Ok, what I want this code to do, is the equivalent of the following macro code, but in Lua:
The Macro:
/use item:bag,slot
if incombat == false then
-- button:SetAttribute("type","item")
-- button:SetAttribute("player",item)
-- button:SetAttribute("item",item)
-- button:SetAttribute("unit","player")
-- button:SetAttribute("helpbutton","helpable")
-- button:SetAttribute("unit-helpable","target")
-- button:SetAttribute("item",item)
endAt least I THINK that's how you'd handle it...the "helpbutton" attribute would only exist if you have a helpable target, and would set your "unit" attribute to "target" in that case, otherwise, your "unit" attribute would be set to "player" -- am I interpreting the UI database correctly on how this kind of thing works?
(the initial check on combat is necessary, because the SetAttribute method is protected)
Post by
HighFive
Firstly, I have
no
idea what you're trying to do there.
Secondly, I'm pretty sure the following is what you're looking for:button:SetAttribute('*type*', 'macro')
button:SetAttribute('macrotext', '/use bag slot')
Post by
RedwoodElf
Well that wouldn't work, because its not the WORDS "bag" and "slot" I need, but the integer variables bag and slot...though I suppose this would work:
button:SetAttribute('macrotext', '/use '..bag..' '..slot)
What I wanted to do is figure out how the 'helpbutton' attribute can be related to the 'unit' attribute...the example I have is this:
button:SetAttribute("unit","target")
button:SetAttribute("harmbutton","pain")
button:SetAttribute("helpbutton","shield")
button:SetAttribute("*spell-pain","Shadow Word: Pain")
button:SetAttribute("*spell-shield","Power Word: Shield")
According to the text, "harmbutton" and "helpbutton" define a suffix,based on the players' target. Though reading it again, it's based on the "unit" attribute, so I should probably set that as "target" first, and then set it to "player" after defining the "unit-harmbutton" attribute. But then, if you change the "unit" attribute, would that retroactively change the previously assigned attribute? Probably not, unless they're passed by reference.
I wanted to figure out if something similar could be set up to set the unit attribute to "player" if the player has no help-able target, and to "target" otherwise.
The reason I wanted to do it this way is, the addon I'm working on will have numerous dynamically created buttons, and only ONE cares what the user's target is, and rather than have just one of them defined as a macro button and all the others another kind of button, I wanted to see if the 'harmbutton' and 'helpbutton' attributes could be used to handle it programatically.
Post by
Wanderingfox
If memory serves, they work like this:
button:SetAttribute("unit", "target")
button:SetAttribute("harmbutton", "pain")
button:SetAttribute("helpbutton", "shield")
button:SetAttribute("type", "spell')
button:SetAttribute("spell-pain", "Shadow Word: Pain")
button:SetAttribute("spell-shield", "Power Word: Shield")
It's been a long long time since I looked at the API for secure buttons though, so you may be better off looking at something like autobar and seeing how they do it.
Not sure how to dynamically change the target, however. I know autobar does it though...
edit:
"If the button is remapped by the "harmbutton" or "helpbutton" attributes, the value of the "unit" attribute is reevaluated with the new button suffix: it is therefore to make a button that would check the hostility of one unit, and perform a reactive action on an entirely different unit. "
From WoW Wiki suggest that re-assigning the value of unit should change the value of the target. Give the following a try:
button:SetAttribute("unit", "target")
button:SetAttribute("harmbutton", "pain")
button:SetAttribute("unit", "player")
button:SetAttribute("helpbutton", "shield")
button:SetAttribute("type", "spell')
button:SetAttribute("spell-pain", "Shadow Word: Pain")
button:SetAttribute("spell-shield", "Power Word: Shield")
Post by
RedwoodElf
So, the value of the 'unit' attribute only needs to be set up to the point where you set the 'harmbutton' attribute, then it can be reset to 'player' and used for 'helpbutton' attribute without affecting the previously set 'harmbutton' attribute?
Post by
RedwoodElf
Hmn...maybe it's unnecessary to bother checking...if I use a macro button, I may be limited to 255 characters of functionality, but at least I know how to code complex behavior in a macro (and I don't think putting in front of, say, food or a potion will prevent it from working.)
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.