View Single Post
09/26/22, 01:12 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,012
The game provides events for things like that and you need to register a callback function in your addon to this event.
https://wiki.esoui.com/Events

Code:
 EVENT_ACTIVE_WEAPON_PAIR_CHANGED (number eventCode, ActiveWeaponPair activeWeaponPair, boolean locked)
ActiveWeaponPair can be one of these globals: https://wiki.esoui.com/Globals#ActiveWeaponPair


Same like starting your addon via EVENT_MANAGER:RegisterforEvent("YourAddonName_event_AddOnLoaded", EVENT_ADD_ON_LOADED, callbackFuncForEventAddOnLoaded) you need to do soemthing like:


Lua Code:
  1. local function callbackFuncForEventActiveWeaponPairSwapped(eventId, activeWeaponPairId, locked)
  2.   if activeWeaponPairId == ACTIVE_WEAPON_PAIR_MAIN then
  3.  ---your code here for weapon bar 1
  4.   elseif activeWeaponPairId == ACTIVE_WEAPON_PAIR_BACKUP then
  5.  ---your code here for weapon bar 2
  6.   end
  7. end
  8.  
  9. EVENT_MANAGER:RegisterforEvent("YourAddonName_event_active_weapon_pair_swapped", EVENT_ACTIVE_WEAPON_PAIR_CHANGED , callbackFuncForEventActiveWeaponPairSwapped)


You can find getting started, examples and tutorials here, right side:
https://wiki.esoui.com/Main_Page
  Reply With Quote