Thread Tools Display Modes
01-09-21, 07:18 PM   #1
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
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?
  Reply With Quote
01-09-21, 08:18 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
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.
__________________
  Reply With Quote
01-09-21, 11:39 PM   #3
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Using one AddOn to change another AddOn's variables?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off