Thread Tools Display Modes
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
03/01/17, 01:40 PM   #2
Fetaro
Join Date: Nov 2015
Posts: 2
NVM, just found why and the fix. Really sorry (was trying to fix it for more than hour)
  Reply With Quote
03/04/17, 08:29 AM   #3
AssemblerManiac
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 51
Originally Posted by Fetaro View Post
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!".
  Reply With Quote

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

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