Thread Tools Display Modes
10-06-14, 06:01 PM   #1
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
How to build custom pet action buttons?

I would like to create some pet action buttons.

I'm using secure buttons with type/pet and action/1-10, which is working as expected.
But ... of course my custom buttons do not provide the right click functionality of the Blizzard pet buttons (enable/disable autocast if spell).

I can't figure out how I could add this. The Bilzzard stuff is:
Lua Code:
  1. function PetActionButton_OnClick (self, button)
  2.     if ( button == "LeftButton" ) then
  3.         CastPetAction(self:GetID());
  4.     else
  5.         TogglePetAutocast(self:GetID());
  6.     end
  7. end
TogglePetAutocast is protected. :/
The only thing I could use is the macro
Code:
/petautocasttoggle <spellname>
But obv. I can't query the spell name from the pet bar action button within my secure buttons code.

Is there really no option to use pet action buttons except re-using the Blizzard buttons??

Last edited by Duugu : 10-06-14 at 06:04 PM.
  Reply With Quote
10-06-14, 06:56 PM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
You have a few options. For one, I believe you can actually inherit the pet button template and then set the IDs on all buttons. I think Bartender does that for shapeshift buttons. The more waterproof solution would be to either bind the right click to macrotext attribute /petautocasttoggle... or, not sure how that'll work if it only takes names. Anyway, you can also just a click attribute on the whole button to click the default button.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-06-14, 07:04 PM   #3
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Hey, thanks Lombra. That sounds good.

Originally Posted by Lombra View Post
The more waterproof solution would be to either bind the right click to macrotext attribute /petautocasttoggle... or, not sure how that'll work if it only takes names.
It only accepts names ... no IDs. But I can't access either names nor IDs of the pet action spells in my secure code. And this would be mandatory as pets could be called/dismissed in combat.

Originally Posted by Lombra View Post
Anyway, you can also just a click attribute on the whole button to click the default button.
Wow. That's it. So simple. Thanks again. I'll do it that way.

[e]
Hm. On a second thought ... it has to be a right click to trigger the autocast on/off thing. :/

I've not tested it right now, but I'm almost sure that inheriting from the pet template will introduce a lot of new problems.

[e2]
Wouldn't a button that inherits vom PetActionButtonTemplate be blocked too if TogglePetAutocast(self:GetID()) is called on click?

[e3]
I'm just realizing that /click passes the mouse buttons to the target button.
I'll try it tomorrow. Thanks again.

Last edited by Duugu : 10-06-14 at 07:36 PM.
  Reply With Quote
10-07-14, 03:39 AM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Duugu View Post
[e2]
Wouldn't a button that inherits vom PetActionButtonTemplate be blocked too if TogglePetAutocast(self:GetID()) is called on click?
Apparently not, unless that all has changed. Because the OnClick was set securely, and the function is secure, or something. But yeah it's possible that it may introduce other problems. /click should be the best solution if it works and if the target buttons' OnClick scripts doesn't do unwanted stuff.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-07-14, 11:00 AM   #5
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
Ok, I got this working now. It's even more complicated and stupid than I thought.

"type/click" expects a object in "clickbutton". It doesn't work with a frame name. :/
In my secure code PetActionButtonx obv. isn't a valid reference.
So I tried to pre-set a frame reference via unsecure code. Like
Lua Code:
  1. BABHeader:SetFrameRef("PetActionButton1", _G["PetActionButton1"])
Then I tried to use this in my secure code:
Lua Code:
  1. local tbutton = self:GetFrameRef("BABHeader"):GetFrameRef("PetActionButton1")
  2. print(tbutton:GetName())
  3. self:SetAttribute("type2", "click")
  4. self:SetAttribute("clickbutton2", tbutton)
Which printed the string "PetActionButton1" and as a total surprise triggered the error
6x FrameXML\SecureTemplates.lua:542: attempt to call method "IsForbidden" (a nil value)
on a right click.

Must be another bug within the secure button stuff (see http://www.wowinterface.com/forums/s...493#post297493)
Seems as I have to set the clickbutton2/frameref thing via unsecure code. :/

Last edited by Duugu : 10-07-14 at 11:12 AM.
  Reply With Quote
10-07-14, 11:49 AM   #6
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Originally Posted by Duugu View Post
In my secure code PetActionButtonx obv. isn't a valid reference.
Why do you need to do it securely?
__________________
Grab your sword and fight the Horde!
  Reply With Quote
10-07-14, 12:00 PM   #7
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
I would like to build a bar that supports dragging pet buttons in combat and states that change the button actions.

Like
state 1 = type/spell
state 2 = type/pet

To do this I have to set the buttons type attribute at OnStateChanged.
And to fully support type/pet on a state change I'll have to securely set type2/clickbutton2 to the actual pet bar button ... which is not possible due to the broken GetFrameRef() function. :/

Whatever ... I'll skip that and use a "fixed" pet bar. It's not worth the trouble.

Last edited by Duugu : 10-07-14 at 12:04 PM.
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » How to build custom pet action buttons?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off