This is the TOC:
UIMod.toc
Lua Code:
## Interface: 40200
## Title: UI Modifier
## Notes: Modifies other addons that change the UI
## Author: Krainz
## Version: 1.0
core.xml
core.lua
core.lua
Lua Code:
local addon, ns = ...
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_ENTERING_WORLD")
f:RegisterEvent("PLAYER_LOGIN");
f:SetScript("OnEvent", function(self, event, ...)
local garrisonType = C_Garrison.GetLandingPageGarrisonType()
local covenantID = C_Covenants.GetActiveCovenantID()
local gwbutton = GwGarrisonButton
if event == "PLAYER_ENTERING_WORLD" then
print("UIMOD: Hello! Hello " .. event);
print(covenantID);
if gwbutton then
print("UIMOD Entering World: GW2 UI Garrison Button is shown. Hiding.");
gwbutton:Hide();
end
-- if not covenantID=0 or garrisonType=3 then
-- print("UIMOD: Covenant Chosen or Order Hall enabled.");
-- if gwbutton and gwbutton:IsShown() then
-- print("UIMOD: GW2 UI Garrison Button is shown. Hiding.");
-- gwbutton:Hide();
-- end
-- end
elseif event == "PLAYER_LOGIN" then
print("UIMOD: Hello! Hello " .. event);
print(covenantID);
if gwbutton then
print("UIMOD Player Login: GW2 UI Garrison Button is shown. Hiding.");
gwbutton:Hide();
end
end
end)
local UIMod_UpdateInterval = 1.0; -- How often the OnUpdate code will run (in seconds)
function UIMod_OnUpdate(self, elapsed)
local gwbutton = GwGarrisonButton
self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;
if (self.TimeSinceLastUpdate > UIMod_UpdateInterval) then
print("UIMOD OnUpdate");
if gwbutton then
print("UIMOD OnUpdate: GW2 UI Garrison Button is shown. Hiding.");
gwbutton:Hide();
end
--
self.TimeSinceLastUpdate = 0;
end
end
core.xml
Lua Code:
<Ui ...>
<Frame ...>
...
<Scripts>
<OnLoad>self.TimeSinceLastUpdate = 0 </OnLoad>
<OnUpdate function="UIMod_OnUpdate" />
</Scripts>
</Frame>
</Ui>
I get the following LUA error at login:
Message: Interface\AddOns\UIMod\core.xml(1): error: not well-formed (invalid token)
Time: Mon Dec 14 20:41:58 2020
Count: 3
I also get the following debug messages I set up to make sure each step is working as intended:
08:43:19 | UIMOD: Hello! Hello PLAYER_LOGIN
08:43:19 | 0
08:43:19 | UIMOD Player Login: GW2 UI Garrison Button is shown. Hiding.
08:43:23 | UIMOD: Hello! Hello PLAYER_ENTERING_WORLD
08:43:23 | 0
08:43:23 | UIMOD Entering World: GW2 UI Garrison Button is shown. Hiding.
What happens is: the button doesn't get hidden and the OnUpdate script doesn't seem to be running.
However, if I just type the following:
/script local gwgarrison=GwGarrisonButton if gwgarrison then gwgarrison:Hide(); end
|
Then the button is properly hidden. I noticed that, however, the GW2 UI addon later on makes the button reappear, which is why the OnUpdate function is important.
Any ideas to what I may be doing wrong?