View Single Post
04/13/15, 02:34 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
I think you need to put it into the callback function of the event_player_activated so it gets called everytime a zonechage/reloadui takes place:
Lua Code:
  1. local function Callback_Player_Activated(...)
  2. --remove borders at action buttons
  3. for slotNum = 3, 9 do
  4.         local button = ZO_ActionBar_GetButton(slotNum).button
  5.         button:SetNormalTexture("")
  6.         button:SetPressedTexture("")
  7.         button:SetDisabledTexture("")
  8.         end
  9. end
  10.  
  11. --Put this somewhere where your addon gets initialized, e.g. inside callback function of EVENT_ADDON_ON_LOAD or just at the bottom of your addon   
  12. --Register for the zone change/player ready event
  13.     EVENT_MANAGER:RegisterForEvent("MyAddonName", EVENT_PLAYER_ACTIVATED, Callback_Player_Activated)

Like written in the code the addon should load some function as it loads up, by event EVENT_ADDON_ON_LOAD. Replace MyAddonName with the name of your addon, like the lua filename is.

Lua Code:
  1. local function Addon_Loaded(eventCode, addOnName)
  2. --Is this addon found? Put your addon's name here!!!
  3.     if(addOnName ~= "MyAddonName") then
  4.         return
  5.     end
  6.     --Unregister this event again so it isn't fired again after this addon has beend reckognized
  7.     EVENT_MANAGER:UnregisterForEvent("MyAddonName", EVENT_ADD_ON_LOADED)
  8.  
  9.     --Register for the zone change/player ready event
  10.     EVENT_MANAGER:RegisterForEvent("MyAddonName", EVENT_PLAYER_ACTIVATED, Callback_Player_Activated)
  11.  
  12. end

At the bottom of your addon's lua file put this then to register the event on addon load callback function:
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("MyAddonName", EVENT_ADD_ON_LOADED, Addon_Loaded)


About the weapon bar change:
I do not know how to check on this but I'll have a look.

EDIT:

There is an event for this too. So put this into the ON ADDOn LOAD event callback function:
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("YourAddonName", EVENT_ACTIVE_WEAPON_PAIR_CHANGED, WeaponSwapped)

And this somewhere above:

Lua Code:
  1. local function WeaponSwapped(...)
  2. --remove borders at action buttons
  3. for slotNum = 3, 9 do
  4.         local button = ZO_ActionBar_GetButton(slotNum).button
  5.         button:SetNormalTexture("")
  6.         button:SetPressedTexture("")
  7.         button:SetDisabledTexture("")
  8.         end
  9. end
  10. end

As the code is duplicate now try to put it in a nother local function and then call the function inside the Weapon swapped callback function AND the player activated function instead.

Last edited by Baertram : 04/13/15 at 02:39 PM.
  Reply With Quote