WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Using one AddOn to change another AddOn's variables? (https://www.wowinterface.com/forums/showthread.php?t=58538)

Krainz 01-09-21 07:18 PM

Using one AddOn to change another AddOn's variables?
 
Hello again,

The GW2UI addon has the following variables

Lua Code:
  1. local TRACKER_TYPE_COLOR = {}
  2. GW.TRACKER_TYPE_COLOR = TRACKER_TYPE_COLOR
  3. TRACKER_TYPE_COLOR["QUEST"] = {r = 221 / 255, g = 198 / 255, b = 68 / 255}
  4. TRACKER_TYPE_COLOR["CAMPAIGN"] = {r = 121 / 255, g = 222 / 255, b = 47 / 255}
  5. TRACKER_TYPE_COLOR["EVENT"] = {r = 240 / 255, g = 121 / 255, b = 37 / 255}
  6. TRACKER_TYPE_COLOR["BONUS"] = {r = 240 / 255, g = 121 / 255, b = 37 / 255}
  7. TRACKER_TYPE_COLOR["SCENARIO"] = {r = 171 / 255, g = 37 / 255, b = 240 / 255}
  8. TRACKER_TYPE_COLOR["BOSS"] = {r = 240 / 255, g = 37 / 255, b = 37 / 255}
  9. TRACKER_TYPE_COLOR["ARENA"] = {r = 240 / 255, g = 37 / 255, b = 37 / 255}
  10. TRACKER_TYPE_COLOR["ACHIEVEMENT"] = {r = 37 / 255, g = 240 / 255, b = 172 / 255}
  11. TRACKER_TYPE_COLOR["DAILY"] = {r = 68 / 255, g = 192 / 255, b = 250 / 255}
  12.  
  13. local TARGET_FRAME_ART = {
  14.     ["minus"] = "Interface/AddOns/GW2_UI/textures/targetshadow",
  15.     ["normal"] = "Interface/AddOns/GW2_UI/textures/targetshadow",
  16.     ["rare"] = "Interface/AddOns/GW2_UI/textures/targetShadowRare",
  17.     ["rareelite"] = "Interface/AddOns/GW2_UI/textures/targetShadowRare",
  18.     ["worldboss"] = "Interface/AddOns/GW2_UI/textures/targetshadow_boss",
  19.     ["boss"] = "Interface/AddOns/GW2_UI/textures/targetshadow_boss",
  20.     ["prestige1"] = "Interface/AddOns/GW2_UI/textures/targetshadow_p1",
  21.     ["prestige2"] = "Interface/AddOns/GW2_UI/textures/targetshadow_p2",
  22.     ["prestige3"] = "Interface/AddOns/GW2_UI/textures/targetshadow_p3",
  23.     ["prestige4"] = "Interface/AddOns/GW2_UI/textures/targetshadow_p4",
  24.     ["realboss"] = "Interface/AddOns/GW2_UI/textures/targetshadow-raidboss"
  25. }
  26. GW.TARGET_FRAME_ART = TARGET_FRAME_ART

Is it possible to use my own addon to change those variables without having to edit the GW2_UI code?


If so, what are the steps I should take?

I imagine it's something along the lines of handling the player_login event, and then...? just re-defining the variable?

Xrystal 01-09-21 08:18 PM

Only if the GW variable is not defined local. Otherwise none of those variables are accessible outside of the addon.

But I suspect GW is the variable they use as their addon wide variable so that any file in their addon can access it but not other addons.

If it is possible, you would handle ADDON_LOADED event and watch for the addon to be loaded and utilise any accessible elements after that point.

Kanegasi 01-09-21 11:39 PM

The GW table is indeed their local addon table. This is at the top of their core/consts.lua file (where OP's code is)

local _, GW = ...

GW is not accessible outside of the addon.


All times are GMT -6. The time now is 05:58 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI