View Single Post
12-13-20, 10:53 AM   #1
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
One addon modifying another?

I need to make my own addon that modifies a few others so that I don't have to modify their files every time they have an update.

So I went to look into how GW2 UI interacts with the Immersion addon:

Lua Code:
  1. local _, GW = ...
  2.  
  3. local function SkinImmersionAddonFrame()
  4.     local ImmersionFrame = _G.ImmersionFrame
  5.  
  6.     if ImmersionFrame then
  7.  
  8.         ImmersionFrame.TalkBox.BackgroundFrame.TextBackground:SetTexture("Interface/AddOns/GW2_UI/textures/party/manage-group-bg")
  9.  
  10.         ImmersionFrame.TalkBox.Hilite:Hide()
  11.  
  12.         ImmersionFrame.TalkBox.MainFrame.Indicator:SetPoint("TOPRIGHT", -56, -13)
  13.     end
  14. end
  15. GW.SkinImmersionAddonFrame = SkinImmersionAddonFrame

There are two things I don't understand in that code:

1. There is a local variable defined, ImmersionFrame. But what is _G.ImmersionFrame? I know that ImmersionFrame is a frame defined in the Immersion addon's XML files, but why the _G? What does it do?

2. The bit that says 'if ImmersionFrame then' checks if the ImmersionFrame exists, correct? How does the GW2 UI addon guarantee that it's going to overwrite what's originally stated in the Immersion addon?
  Reply With Quote