Hi! I am new to Addon development, and I have been fiddling around trying things to get a hold on things.
However, I am stuck on something I don't quite understand yet...
I have followed this tutorial:
and from there I have added a auto ready check accept when using LFG
Lua Code:
EVENT_MANAGER:RegisterForEvent(self.name, EVENT_GROUPING_TOOLS_READY_CHECK_UPDATED, self.OnLFGReadyCheckState)
[...]
function RemiCustomAddon.OnLFGReadyCheckState(event)
if HasLFGReadyCheckNotification() then
AcceptLFGReadyCheckNotification()
end
end
And it works perfectly!
I just wanted to add now a message display that tells me when I'm close to full on my bag (less than 10 space left). I copied everything I did for the combat system in the tutorial (which still works well) and created a new XML file for this. However, whenever the addon should update with the message, I get the infamous "nil index...".
Could someone give me a hand?
.lua file:
Lua Code:
EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_ACTIVATED, self.DoesBagHaveSpace)
[...]
function RemiCustomAddon.DoesBagHaveSpace(eventCode, initial)
itemSpace = GetNumBagFreeSlots(1)
if itemSpace < 10 then
RemiCustomAddonIndicator:SetHidden(false) -- Here is the faulty line
end
end
.xml file:
Code:
<GuiXml>
<Controls>
<TopLevelControl name="FightIndicator" mouseEnabled="true" movable="true" clampedToScreen="true">
<Dimensions x="200" y="25" />
<Anchor point="BOTTOM" relativeTo="GuiRoot" relativePoint="CENTER" offsetY="-20" />
<OnInitialized>
-- LUA code here. This is where you'd check to see if the control needs to be hidden or not.
FightIndicator:SetHidden(not IsUnitInCombat('player'))
</OnInitialized>
<OnMoveStop>
RemiCustomAddon.OnIndicatorMoveStopFight()
</OnMoveStop>
<Controls>
<Label name="$(parent)Label" width="200" height="25" font="ZoFontWinH1" inheritAlpha="true" color="FF0000"
wrapMode="TRUNCATE" verticalAlignment="TOP" horizontalAlignment="CENTER" text="Fighting!">
<Anchor point="TOP" relativeTo="$(parent)" relativePoint="TOP" />
</Label>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>
.txt file:
Code:
## Title: RemiCustomAddon
## APIVersion: 100030
## SavedVariables: RemiCustomAddonSavedVariables
RemiCustomAddon.lua
RemiCustomAddon.xml
Fight.xml
Note that I tried putting .xml files before AND after the .lua, to no avail.
Thanks in advance!