View Single Post
Unread 07-04-12, 04:58 PM   #4
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 1,367
Ok I need some help.

This is the code for my actionbar 1
Lua Code:
  1. -----------------------------
  2.   -- ACTION BUTTON CONTROLLER
  3.   -----------------------------
  4.  
  5.   local function getBarPage()
  6.     print("getting pages")
  7.     if ( HasBonusActionBar() or HasOverrideActionBar() or HasVehicleActionBar() or HasTempShapeshiftActionBar() ) then
  8.       if (HasVehicleActionBar()) then
  9.         return GetVehicleBarIndex()
  10.       elseif (HasOverrideActionBar()) then
  11.         return GetOverrideBarIndex()
  12.       elseif (HasTempShapeshiftActionBar()) then
  13.         return GetTempShapeshiftBarIndex()
  14.       elseif (HasBonusActionBar() and GetActionBarPage() == 1) then
  15.         return GetBonusBarIndex()
  16.       else
  17.         return GetActionBarPage()
  18.       end
  19.     else
  20.       return GetActionBarPage()
  21.     end
  22.   end
  23.  
  24.   for id = 1, NUM_ACTIONBAR_BUTTONS do
  25.     local button = _G["ActionButton"..id]
  26.     frame:SetFrameRef(button:GetName(), button)
  27.   end
  28.   frame:Execute(([[
  29.     buttons = table.new()
  30.     for id = 1, %s do
  31.       buttons[id] = self:GetFrameRef("ActionButton"..id)
  32.     end
  33.   ]]):format(NUM_ACTIONBAR_BUTTONS))
  34.   frame:SetAttribute('_onstate-page', ([[
  35.     if not newstate then return end
  36.     newstate = tonumber(newstate)
  37.     for id = 1, %s do
  38.       buttons[id]:SetAttribute("actionpage", newstate)
  39.     end
  40.   ]]):format(NUM_ACTIONBAR_BUTTONS))
  41.   RegisterStateDriver(frame, "page", getBarPage())

The problem is that the stateid is wrong. It is set to "page" but there is no more page-swapping, thus the statedriver does not get called as often as I need it.

If I do a /reload the correct bar will be loaded on the given value from getBarPage().

Question: Are there any other stateids that I could use?

I need to call the state driver on the following events. But how does an event correlate to a state-id?
Lua Code:
  1. event == "PLAYER_ENTERING_WORLD"
  2. event == "UPDATE_BONUS_ACTIONBAR"
  3. event == "UPDATE_VEHICLE_ACTIONBAR"
  4. event == "UPDATE_OVERRIDE_ACTIONBAR"
  5. event == "ACTIONBAR_PAGE_CHANGED"


The best solution I came up with is:

Lua Code:
  1. local function getPage()
  2.     print("getting pages")
  3.     if ( HasBonusActionBar() or HasOverrideActionBar() or HasVehicleActionBar() or HasTempShapeshiftActionBar() ) then
  4.       if (HasVehicleActionBar()) then
  5.         return GetVehicleBarIndex()
  6.       elseif (HasOverrideActionBar()) then
  7.         return GetOverrideBarIndex()
  8.       elseif (HasTempShapeshiftActionBar()) then
  9.         return GetTempShapeshiftBarIndex()
  10.       elseif (HasBonusActionBar() and GetActionBarPage() == 1) then
  11.         return GetBonusBarIndex()
  12.       else
  13.         return GetActionBarPage()
  14.       end
  15.     else
  16.       return GetActionBarPage()
  17.     end
  18.   end
  19.  
  20.   for id = 1, NUM_ACTIONBAR_BUTTONS do
  21.     local button = _G["ActionButton"..id]
  22.     frame:SetFrameRef(button:GetName(), button)
  23.   end
  24.  
  25.   frame:SetScript("OnEvent", function(self, event)
  26.     frame:Execute(([[
  27.       buttons = table.new()
  28.       for id = 1, %s do
  29.         buttons[id] = self:GetFrameRef("ActionButton"..id)
  30.         buttons[id]:SetAttribute("actionpage", %s)
  31.       end
  32.     ]]):format(NUM_ACTIONBAR_BUTTONS, getPage()))
  33.   end)
  34.  
  35.   frame:RegisterEvent("PLAYER_ENTERING_WORLD")
  36.   frame:RegisterEvent("UPDATE_BONUS_ACTIONBAR")
  37.   frame:RegisterEvent("UPDATE_VEHICLE_ACTIONBAR")
  38.   frame:RegisterEvent("UPDATE_OVERRIDE_ACTIONBAR")
  39.   frame:RegisterEvent("ACTIONBAR_PAGE_CHANGED")

That actually works. But as soon as I exit the vehicle in combat I get a totally wierd taint.

Code:
7/5 00:54:45.243  Global variable rGetPoint tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:12
7/5 00:54:45.243  Global variable rResetToDefaultPoint tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:23
7/5 00:54:45.243  Global variable rResetToPoint tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:30
7/5 00:54:45.243  Global variable rUnlockFrame tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:43
7/5 00:54:45.243  Global variable rLockFrame tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:58
7/5 00:54:45.243  Global variable rUnlockAllFrames tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:71
7/5 00:54:45.243  Global variable rLockAllFrames tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:80
7/5 00:54:45.243  Global variable rResetAllFramesToDefault tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:89
7/5 00:54:45.243  Global variable rCreateDragFrame tainted by rLib - Interface\AddOns\rLib\core\dragframe.lua:98
7/5 00:54:45.243  Global variable rCreateSlashCmdFunction tainted by rLib - Interface\AddOns\rLib\core\slashcmd.lua:14
7/5 00:54:45.243  Global variable rButtonBarFader tainted by rLib - Interface\AddOns\rLib\core\fader.lua:15
7/5 00:54:45.243  Global variable rFrameFader tainted by rLib - Interface\AddOns\rLib\core\fader.lua:32
7/5 00:54:45.243  Global variable SLASH_rabs1 tainted by rActionBarStyler - Interface\AddOns\rActionBarStyler\core\slashcmd.lua:24
7/5 00:54:45.321  Global variable ACTIVE_CHAT_EDIT_BOX tainted by rActionBarStyler - Interface\FrameXML\ChatFrame.lua:3782 ChatEdit_DeactivateChat()
7/5 00:54:45.321      Interface\FrameXML\InterfaceOptionsPanels.lua:981 InterfaceOptionsSocialPanelChatStyle_SetChatStyle()
7/5 00:54:45.321      Interface\FrameXML\InterfaceOptionsPanels.lua:907
7/5 00:54:45.321  Execution tainted by rActionBarStyler while reading ACTIVE_CHAT_EDIT_BOX - Interface\FrameXML\ChatFrame.lua:3781 ChatEdit_DeactivateChat()
7/5 00:54:45.321      Interface\FrameXML\ChatFrame.lua:3727 ChatEdit_OnEditFocusLost()
7/5 00:54:45.321      ChatFrame1EditBox:OnEditFocusLost()
7/5 00:54:45.321      ChatFrame1EditBox:ClearFocus()
7/5 00:54:45.321      Interface\FrameXML\ChatFrame.lua:3769 ChatEdit_SetDeactivated()
7/5 00:54:45.321      Interface\FrameXML\ChatFrame.lua:3785 ChatEdit_DeactivateChat()
7/5 00:54:45.321      Interface\FrameXML\InterfaceOptionsPanels.lua:981 InterfaceOptionsSocialPanelChatStyle_SetChatStyle()
7/5 00:54:45.321      Interface\FrameXML\InterfaceOptionsPanels.lua:907
How can I get a taint from my own lib?

The only thing that I could think of that nets me the taint is calling SetAttribute on the button inside EXECUTE...but how should I do it otherwise?
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)

Last edited by zork : 07-05-12 at 01:37 AM.
zork is offline