View Single Post
12-15-20, 06:43 AM   #9
Krainz
A Wyrmkin Dreamwalker
Join Date: Oct 2016
Posts: 57
Yeah I used a XML file because the wowwiki article instructed to...

So I shouldn't use XML files when I'm not creating actually graphical UI frames?

Originally Posted by Kanegasi View Post
Put the OnUpdate in Lua.

Lua Code:
  1. self.TimeSinceLastUpdate = 0
  2.  
  3. f:SetScript("OnUpdate",function(self,elapsed)
  4.     local gwbutton = GwGarrisonButton
  5.   self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;
  6.  
  7.  
  8.   if (self.TimeSinceLastUpdate > UIMod_UpdateInterval) then
  9.     print("UIMOD OnUpdate");
  10.         if gwbutton then
  11.             print("UIMOD OnUpdate: GW2 UI Garrison Button is shown. Hiding.");
  12.             gwbutton:Hide();
  13.         end
  14.     --
  15.  
  16.     self.TimeSinceLastUpdate = 0;
  17.   end
  18. end)

This is my core.lua now but the OnUpdate funcion still isn't happening. Not even firing the debug prints

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. UIMod_UpdateInterval = 1.0; -- How often the OnUpdate code will run (in seconds)
  41.  
  42.  
  43. self.TimeSinceLastUpdate = 0
  44.  
  45. f:SetScript("OnUpdate",function(self,elapsed)
  46.         local gwbutton = GwGarrisonButton
  47.     self.TimeSinceLastUpdate = self.TimeSinceLastUpdate + elapsed;
  48.  
  49.  
  50.     if (self.TimeSinceLastUpdate > UIMod_UpdateInterval) then
  51.         print("UIMOD OnUpdate");
  52.                 if gwbutton then
  53.                         print("UIMOD OnUpdate: GW2 UI Garrison Button is shown. Hiding.");
  54.                         gwbutton:Hide();
  55.                 end
  56.         --
  57.  
  58.         self.TimeSinceLastUpdate = 0;
  59.     end
  60. end)

I tried removing core.xml from the TOC to no avail

Last edited by Krainz : 12-15-20 at 06:51 AM.
  Reply With Quote