ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   All addons loaded are nil (https://www.esoui.com/forums/showthread.php?t=6679)

StackofCups 12/12/16 09:48 PM

All addons loaded are nil
 
So, everything is working fine as far as my other addons go. This is my first time trying to write an addon and I'm trying to d("hello world") withing my EVENT_ADD_ON_LOADED callback. I had the if addonName == MyAddon.name then d("hello world") but it never fired. Other things fired at other places so I eventually removed the if statement. Turns out every addonName is just nil when passed into this callback. I really don't understand why. Here's my code so far:
Code:

-- Addon Container
TheDeeps = {}
-- Container properties
TheDeeps.name = "TheDeeps"
TheDeeps.CombatEvents = {}

-- Initialization Function
function TheDeeps:OnAddOnLoaded(event, addonName)

        zo_callLater (function () d (addonName) end, 3000) -- addonName is always nil. I see nil the number of times in my chat log equal to how many addons I have installed.

        if addonName == TheDeeps.name then
                zo_callLater(function() d(addonName) end, 3000)
        end
end


-- Register for loaded event to trigger addon initialization
        EVENT_MANAGER:RegisterForEvent(TheDeeps.name, EVENT_ADD_ON_LOADED, TheDeeps.OnAddOnLoaded)


votan 12/13/16 02:13 AM

Hi.

Your OnAddOnLoaded signature is wrong the way you are using it.
Your either change the signature to:
Code:

function TheDeeps.OnAddOnLoaded(event, addonName)
or change the way it is called:
Code:

EVENT_MANAGER:RegisterForEvent(TheDeeps.name, EVENT_ADD_ON_LOADED, function (...) TheDeeps:OnAddOnLoaded(...) end)
Which is the same as:
Code:

EVENT_MANAGER:RegisterForEvent(TheDeeps.name, EVENT_ADD_ON_LOADED, function (...) TheDeeps.OnAddOnLoaded(TheDeeps, ...) end)
That's the way the colon works in Lua. It saves you from writing the "instance" (TheDeeps) twice. And adds an implicit parameter "self".


All times are GMT -6. The time now is 04:00 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI