Thread Tools Display Modes
Prev Previous Post   Next Post Next
03/01/17, 01:28 PM   #1
Fetaro
Join Date: Nov 2015
Posts: 2
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
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Noobish problem : "function expected instead of nil" when using saved variables


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