Help with first addon, Lua not initializing?
Hey there, I am trying to write a small add-on as a learning project, that counts number of lockpicks left and increments a counter whenever a lockpick-success event occurs.
So far I've written the txt, xml and lua files based on the AddOn scripting guides from the EsoUI wiki, and I can see the GUI (xml) in-game, however it seems that the LUA file does not load as it doesn't have any functionality beyond showing the strings set to labels in the XML. (Saving the new position of the UI elements to savedvariables does not seem to work either, so the xml is set to where I want it to be) Steps I've taken to troubleshoot: 1. DebugViewer not throwing errors 2. Checked for typos etc. (maybe incomplete) The required functionality is: 1. User can see number of lockpicks remaining on character load 2. User can count number of safeboxes/treasure chests lockpicked I'm quite new and learning, so any input would be appreciated, thanks in advance. Screenshot of GUI https://ibb.co/dLmXgs1 txt file Code:
## Title: TreasureCounter Code:
<GuiXml> Code:
--Variables |
If you move the window, do you get a nil error ?
Did you check for case-sensitive typos in the addon name and/or trailing white space in the lua filename line? |
Thank you for the response.
Quote:
user:/AddOns/TreasureCounter/TreasureCounter.lua:35: attempt to index a nil value |rstack traceback: user:/AddOns/TreasureCounter/TreasureCounter.lua:35: in function 'TreasureCounter.OnIndicatorMoveStop' Line 35 is: TreasureCounter.savedVariables.left = TreasureCounterWindow:GetLeft() in function OnIndicatorMoveStop Quote:
|
It's EVENT_ADD_ON_LOADED instead of EVENT_ADDON_LOADED.
That's why your initialization function is not executed. |
Quick update;
OK, so the addon started working after restarting the game. I was trying to debug using /reloadui earlier, while tinkering with the code. I didn't make any changes since posting this thread but it seems to work now: https://ibb.co/M56wyqg However, I think there are still some problems with Initialize() or event-calling logic in my code, as the GUI doesn't populate number of lockpicks until CountIncrement() is called by the EVENT_LOCKPICK_SUCCESS register. |
Quote:
I changed the event register to EVENT_ADD_ON_LOADED, but its still not going to Initialize(). I'm seeing this error in DebugViewer: Code:
user:/AddOns/TreasureCounter/TreasureCounter.lua:18: function expected instead of nil |
NewCharacterIdSettings instead of NewCharacterId
|
Quote:
|
All times are GMT -6. The time now is 08:20 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI