View Single Post
04/29/20, 09:19 AM   #1
EscherechiaColi
Join Date: Apr 2020
Posts: 9
Help with XML controls

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:
  1. EVENT_MANAGER:RegisterForEvent(self.name, EVENT_GROUPING_TOOLS_READY_CHECK_UPDATED, self.OnLFGReadyCheckState)
  2. [...]
  3. function RemiCustomAddon.OnLFGReadyCheckState(event)
  4.     if HasLFGReadyCheckNotification() then
  5.         AcceptLFGReadyCheckNotification()
  6.     end
  7. 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:
  1. EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_ACTIVATED, self.DoesBagHaveSpace)
  2. [...]
  3. function RemiCustomAddon.DoesBagHaveSpace(eventCode, initial)
  4.     itemSpace = GetNumBagFreeSlots(1)
  5.     if itemSpace < 10 then
  6.         RemiCustomAddonIndicator:SetHidden(false) -- Here is the faulty line
  7.     end
  8. 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!
  Reply With Quote