View Single Post
12-14-20, 06:00 PM   #1
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
not well-formed error and OnUpdate script not working. Help?

This is the TOC:

UIMod.toc
Lua Code:
  1. ## Interface: 40200
  2. ## Title: UI Modifier
  3. ## Notes: Modifies other addons that change the UI
  4. ## Author: Krainz
  5. ## Version: 1.0
  6.  
  7. core.xml
  8. core.lua

core.lua
Lua Code:
  1. local addon, ns = ...
  2.  
  3. local f = CreateFrame("Frame")
  4.  
  5.  
  6. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  7. f:RegisterEvent("PLAYER_LOGIN");
  8. f:SetScript("OnEvent", function(self, event, ...)
  9.     local garrisonType = C_Garrison.GetLandingPageGarrisonType()
  10.     local covenantID = C_Covenants.GetActiveCovenantID()
  11.     local gwbutton = GwGarrisonButton
  12.     if event == "PLAYER_ENTERING_WORLD" then
  13.         print("UIMOD: Hello! Hello " .. event);
  14.         print(covenantID);
  15.  
  16.         if gwbutton then
  17.             print("UIMOD Entering World: GW2 UI Garrison Button is shown. Hiding.");
  18.             gwbutton:Hide();
  19.         end
  20.  
  21. --      if not covenantID=0 or garrisonType=3 then
  22. --          print("UIMOD: Covenant Chosen or Order Hall enabled.");
  23. --          if gwbutton and gwbutton:IsShown() then
  24. --              print("UIMOD: GW2 UI Garrison Button is shown. Hiding.");
  25. --              gwbutton:Hide();
  26. --          end
  27. --      end
  28.     elseif event == "PLAYER_LOGIN" then
  29.         print("UIMOD: Hello! Hello " .. event);
  30.         print(covenantID);
  31.  
  32.         if gwbutton then
  33.             print("UIMOD Player Login: GW2 UI Garrison Button is shown. Hiding.");
  34.             gwbutton:Hide();
  35.         end
  36.     end
  37. end)
  38.  
  39.  
  40. local UIMod_UpdateInterval = 1.0; -- How often the OnUpdate code will run (in seconds)
  41.  
  42.  
  43. function UIMod_OnUpdate(self, elapsed)
  44.     local gwbutton = GwGarrisonButton
  45.   self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;
  46.  
  47.  
  48.   if (self.TimeSinceLastUpdate > UIMod_UpdateInterval) then
  49.     print("UIMOD OnUpdate");
  50.         if gwbutton then
  51.             print("UIMOD OnUpdate: GW2 UI Garrison Button is shown. Hiding.");
  52.             gwbutton:Hide();
  53.         end
  54.     --
  55.  
  56.     self.TimeSinceLastUpdate = 0;
  57.   end
  58. end

core.xml
Lua Code:
  1. <Ui ...>
  2.   <Frame ...>
  3.     ...
  4.     <Scripts>
  5.       <OnLoad>self.TimeSinceLastUpdate = 0 </OnLoad>
  6.       <OnUpdate function="UIMod_OnUpdate" />
  7.     </Scripts>
  8.   </Frame>
  9. </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?
  Reply With Quote