ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Noobish problem : "function expected instead of nil" when using saved variables (https://www.esoui.com/forums/showthread.php?t=6864)

Fetaro 03/01/17 01:28 PM

Noobish problem : "function expected instead of nil" when using saved variables
 
Hi,

I'm aware that this is a noobish question. But I can't find any solution anywhere. I followed some guides, I've googled, I've read another addons source code. Whatever I try, I have this error : "LegerdemainLog.lua:17: function expected instead of nil".

So, I have this .txt
Code:

## APIVersion: 100018
## Title: LegerdemainLog |c886600 v1.0.0 |r
## Description: |ca0a0a0LegerdemainLog.|r
## Author: |cFF2222Fetaro|r
## SavedVariables: LegerdemainLogSavedDatas

LegerdemainLog.lua

And then, I have this LUA
Code:

LegerdemainLog = {}
LegerdemainLog.name = "LegerdemainLog"

local defaults = {}
 
function LegerdemainLog:Initialize()
        EVENT_MANAGER:RegisterForEvent(self.name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE , self.OnInventorySlotUpdate)
        self.savedDatas = ZO_SavedVars:New("LegerdemainLogSavedDatas", 1, nil, defaults)
end

function LegerdemainLog.OnInventorySlotUpdate(eventCode, bagId, slotId, isNewItem, soundCategory, inventoryUpdateReason, quantity)
  --whatever
end
 
function LegerdemainLog.OnAddOnLoaded(event, addonName)
        if addonName == LegerdemainLog.name then
                LegerdemainLog:Initialize() -- This is line 17
        end
end

EVENT_MANAGER:RegisterForEvent(LegerdemainLog.name, EVENT_ADD_ON_LOADED, LegerdemainLog.OnAddOnLoaded)

The problem doesn't happen when I don't try to used saved variables.

What the hell am I doing wrong ? Please? :3

Fetaro 03/01/17 01:40 PM

NVM, just found why and the fix. Really sorry (was trying to fix it for more than hour)

AssemblerManiac 03/04/17 08:29 AM

Quote:

Originally Posted by Fetaro (Post 30090)
NVM, just found why and the fix. Really sorry (was trying to fix it for more than hour)

When you do manage to find something like this, share the solution so others in the future (who have the same problem) get the benefit of your "Aha!".


All times are GMT -6. The time now is 12:16 PM.

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