View Single Post
04/30/20, 03:28 AM   #10
EscherechiaColi
Join Date: Apr 2020
Posts: 9
Sorry... I thought it would be better that way. So here we go:

Lua Code:
  1. -- First, we create a namespace for our addon by declaring a top-level table that will hold everything else.
  2. RemiCustomAddon = {}
  3.  
  4. -- This isn't strictly necessary, but we'll use this string later when registering events.
  5. -- Better to define it in a single place rather than retyping the same string.
  6. RemiCustomAddon.name = "RemiCustomAddon"
  7.  
  8. function RemiCustomAddon:RestorePositionBagSpace()
  9.     local leftBagSpace = self.savedVariables.leftBagSpace
  10.     local topBagSpace = self.savedVariables.topBagSpace
  11.    
  12.     RemiCustomAddonIndicator:ClearAnchors()
  13.     RemiCustomAddonIndicator:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, leftBagSpace, topBagSpace)
  14. end
  15.  
  16. function RemiCustomAddon:RestorePositionFight()
  17.     local leftFight = self.savedVariables.leftFight
  18.     local topFight = self.savedVariables.topFight
  19.    
  20.     FightIndicator:ClearAnchors()
  21.     FightIndicator:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, leftFight, topFight)
  22. end
  23.  
  24. -- Next we create a function that will initialize our addon
  25. function RemiCustomAddon:Initialize()
  26.     self.inCombat = IsUnitInCombat("player");
  27.    
  28.  
  29.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_COMBAT_STATE, self.OnPlayerCombatState)
  30.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_GROUPING_TOOLS_READY_CHECK_UPDATED, self.OnLFGReadyCheckState)
  31.     EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_ACTIVATED, self.DoesBagHaveSpace)
  32.  
  33.     self.savedVariables = ZO_SavedVars:New("RemiCustomAddonSavedVariables", 1, nil, {})
  34.     self:RestorePositionBagSpace()
  35.     self:RestorePositionFight()
  36. end
  37.  
  38. function RemiCustomAddon.DoesBagHaveSpace(eventCode, initial)
  39.     itemSpace = GetNumBagFreeSlots(1)
  40.     if itemSpace < 10 then
  41.         RemiCustomAddonIndicator:SetHidden(false)
  42.    end
  43. end
  44.  
  45. function RemiCustomAddon.OnLFGReadyCheckState(event)
  46.     if HasLFGReadyCheckNotification() then
  47.         AcceptLFGReadyCheckNotification()
  48.     end
  49. end
  50.  
  51. function RemiCustomAddon.OnPlayerCombatState(event, inCombat)
  52.     -- The ~= operator is "not equal to" in Lua.
  53.     if inCombat ~= RemiCustomAddon.inCombat then
  54.       -- The player's state has changed. Update the stored state...
  55.       RemiCustomAddon.inCombat = inCombat
  56.    
  57.       -- ...and then update the control.
  58.       FightIndicator:SetHidden(not inCombat)
  59.     end
  60. end
  61.  
  62. function RemiCustomAddon.OnIndicatorMoveStopFight()
  63.     RemiCustomAddon.savedVariables.leftFight = FightIndicator:GetLeft()
  64.     RemiCustomAddon.savedVariables.topFight = FightIndicator:GetTop()
  65. end
  66.  
  67. function RemiCustomAddon.OnIndicatorMoveStopBagSpace()
  68.     RemiCustomAddon.savedVariables.leftBagSpace = RemiCustomAddonIndicator:GetLeft()
  69.     RemiCustomAddon.savedVariables.topBagSpace = RemiCustomAddonIndicator:GetTop()
  70. end
  71.  
  72. -- Then we create an event handler function which will be called when the "addon loaded" event
  73. -- occurs. We'll use this to initialize our addon after all of its resources are fully loaded.
  74. function RemiCustomAddon.OnAddOnLoaded(event, addonName)
  75.   -- The event fires each time *any* addon loads - but we only care about when our own addon loads.
  76.   if addonName == RemiCustomAddon.name then
  77.     RemiCustomAddon:Initialize()
  78.   end
  79. end
  80.  
  81. -- Finally, we'll register our event handler function to be called when the proper event occurs.
  82. EVENT_MANAGER:RegisterForEvent(RemiCustomAddon.name, EVENT_ADD_ON_LOADED, RemiCustomAddon.OnAddOnLoaded)

As for the error messages, here it is (expanded):
Code:
user:/AddOns/RemiCustomAddon/RemiCustomAddon.lua:12: attempt to index a nil value
stack traceback:
user:/AddOns/RemiCustomAddon/RemiCustomAddon.lua:12: in function 'RemiCustomAddon:RestorePositionBagSpace'
|caaaaaa<Locals> self = [table:1]{inCombat = F, name = "RemiCustomAddon"} </Locals>|r
user:/AddOns/RemiCustomAddon/RemiCustomAddon.lua:34: in function 'RemiCustomAddon:Initialize'
|caaaaaa<Locals> self = [table:1] </Locals>|r
user:/AddOns/RemiCustomAddon/RemiCustomAddon.lua:77: in function 'RemiCustomAddon.OnAddOnLoaded'
|caaaaaa<Locals> event = 65536, addonName = "RemiCustomAddon" </Locals>|r
But to be honest, I don't really see what to do with this information myself... I don't quite understand what would be missing.

For LibDebugLogger, sorry it took quite a lot of time for me to understand how to use it...
Here is the file:
https://sir.insidi.at/or/logviewer/NVxFbP

As for the .txt file, yes I tried putting .xml files before and after the .lua file, no change. I also already tried removing the OnInitialization code (commenting it with --) to no avail.
  Reply With Quote