Thread Tools Display Modes
12/12/16, 09:48 PM   #1
StackofCups
Join Date: Dec 2016
Posts: 1
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)
  Reply With Quote
12/13/16, 02:13 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
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".
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » All addons loaded are nil

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off