Go to Page... |
Thread Tools | Display Modes |
03-11-15, 06:52 AM | #1 |
SecureActionButtonTemplate - stance/form/vehicle
The documentation on SecureActionButtonTemplate is pretty vague, and thus far I haven't figured out the behaviour completely. If I want to create a secure button that uses the type attribute "action" to cast spells etc, how can I make it so it'll change action depending on which action page is currently occupying the normal action bar?
Since I couldn't figure it out back then, my current approach is using the click type and assigning it to the actual button on the bar. This approach sucks, because it doesn't work with vehicles and pet battles. It only works with stances, forms and paging. Here's a basic visible button in the center of the screen for testing: Lua Code:
Thanks in advance, fellow lua wizards. Last edited by MunkDev : 03-11-15 at 07:31 AM. |
|
03-11-15, 08:27 AM | #2 |
Judging from this code in ActionButton.lua
Code:
function ActionButton_CalculateAction (self, button) if ( not button ) then button = SecureButton_GetEffectiveButton(self); end if ( self:GetID() > 0 ) then local page = SecureButton_GetModifiedAttribute(self, "actionpage", button); if ( not page ) then page = GetActionBarPage(); if ( self.isExtra ) then page = GetExtraBarIndex(); elseif ( self.buttonType == "MULTICASTACTIONBUTTON" ) then page = GetMultiCastBarIndex(); end end return (self:GetID() + ((page - 1) * NUM_ACTIONBAR_BUTTONS)); else return SecureButton_GetModifiedAttribute(self, "action", button) or 1; end end
__________________
This posting is made of 100% recycled electrons. |
|
03-11-15, 09:11 AM | #3 | ||
Lua Code:
Lua Code:
Edit: I hooked that function to try and find out what's going on: Code:
/run hooksecurefunc("ActionButton_CalculateAction", function(...) local s, b = ...; print(s:GetName(), s:GetID(), (s:GetID() + (GetActionBarPage()-1) * NUM_ACTIONBAR_BUTTONS), SecureButton_GetModifiedAttribute(s, "actionpage", b)) end)
Last edited by MunkDev : 03-11-15 at 10:05 AM. |
|||
03-11-15, 10:37 AM | #4 |
Based on the ActionButton_CalculateAction, if you want it act like what you want, you would also control the button's "actionpage" attribute by yourself.
Here is an example to show how to modify the attribute during the combat. 1. Create one manager secure frame to controls the modification. Lua Code:
2. Register the manager to state driver to get the action page based on conditions. Lua Code:
3. Create those action buttons and register them to the Manager Lua Code:
It's an example code from my lib file ActionHandler. I don't have much time to test it, but I think it's enough for your questions. |
|
03-11-15, 10:57 AM | #5 |
This part of ActionBarControler.lua should be what handles switching the bar in the default code:
Lua Code:
The individual ActionButtons are set to use their parent's value, but that'll just save some calls: Lua Code:
Now regarding your problem of updating the attributes on your own frames, using SecureStateDriver and SecureHandlerStateTemplate, like the previous poster also did, is likely the way to go. However, instead of hardcoding all bar ids like he seems to have done, maybe one can clone Blizzard's code. Never used the stuff myself though, so the whole things posted were just dug up quickly.
__________________
This posting is made of 100% recycled electrons. |
|
03-11-15, 10:59 AM | #6 |
Certainly more complicated than I thought it would be. This should suffice.
Just a quick question though and I might be an idiot for asking it; why isn't "Manager" localized? Thank you very much for this! |
|
03-11-15, 01:10 PM | #7 |
Thank you kurapica.igas. I managed to get it working using a modified version of the code you provided
|
|
03-11-15, 06:15 PM | #8 |
In my action system, I don't really need an existed action bar, so I don't use a use parent attribute.
Localized the Manager is because a blizzard's bug, the "control" may not existed in some condition, but it's a long time ago, I don't know if they fix it. Since all the snippets are running in the Manager's environment, it's simple to keep a global variable to make sure I can get it everywhere. |
|
03-11-15, 06:18 PM | #9 |
Ah, I forget it in the first part, the first part should be
Lua Code:
I just extract some code from my files, it's defined in several files, sorry, I missed the important line. Last edited by kurapica.igas : 03-11-15 at 06:22 PM. |
|
03-11-15, 08:21 PM | #10 |
Yes, I figured it all out. This is the code I use for my secure buttons and handler now:
Lua Code:
As you can see, I changed all the inbound references to self already. Last edited by MunkDev : 03-22-15 at 04:11 PM. |
|
03-22-15, 02:20 PM | #11 |
I've just noticed that this solution doesn't seem to work for prowling druids in cat form.
Any ideas? Edit: Solved it! The prowled actionpage is 7, not 8. Changed this bit: Lua Code:
To this: Lua Code:
Last edited by MunkDev : 03-22-15 at 04:11 PM. |
|
WoWInterface » Developer Discussions » Lua/XML Help » SecureActionButtonTemplate - stance/form/vehicle |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|