On a possibly related note: If you have errors in your lua code, the game may throw errors even if that code never runs.
I had a faulty lua statement in SorcererHelper that threw errors on loading a non-sorcerer character, even though this code is the first that runs for the addon:
Lua Code:
local function OnAddOnLoaded(eventCode, addOnName)
if (addOnName == "SorcererHelper") then
if GetUnitClassId("player") ~= 2 then
EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_ADD_ON_LOADED)
EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_PLAYER_ACTIVATED)
EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_ACTION_SLOT_ABILITY_SLOTTED)
EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_ACTIVE_WEAPON_PAIR_CHANGED)
EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_UNIT_ATTRIBUTE_VISUAL_ADDED)
EVENT_MANAGER:UnregisterForEvent("SorcererHelper", EVENT_UNIT_ATTRIBUTE_VISUAL_REMOVED)
do return end
else
SH.SV = ZO_SavedVars:NewAccountWide("SorcererHelper_SavedVariables", 1, nil, SH.Defaults)
SH.CreateSettings()
end
end
end
That "if GetUnitClassId("player") ~= 2" means that unless your character is a sorcerer, the addon will unregister all events and stop.
Even so, a bug in a function in code that never ran threw an "attempt to index a nil value" error. It stumped me for a while until I realized that it's a compile-time error.
I'm guessing the game loads and compiles all code during loading/reloading, and the bug I had gave a compile-time error - which was why it showed up even though the code itself never got called.