Originally Posted by Zierk
Hello,
I am developing an addon that can read, take attachments, take money, and finally delete each piece of mail in your inbox with a single mouse-click on an xml frame. I am getting the following errors from the EsoUI, looking for some help here:
Code:
EsoUI/Ingame/Mail/MailInbox.lua:531: attempt to index a nil value
stack traceback:
EsoUI/Ingame/Mail/MailInbox.lua:531: in function 'MailInbox:RefreshMoneyControls'
EsoUI/Ingame/Mail/MailInbox.lua:562: in function 'MailInbox:OnTakeAttachedMoneySuccess'
EsoUI/Ingame/Mail/MailInbox.lua:51: in function '(anonymous)'
|
Well, without posting a part of the code it's slightly impossible to determine what the error is.
I am using a helper function to identify each mailId and store the "GetMailInfo" data into an array which is called in order to determine if each mail needs to be read, looted or deleted. That information is stored in tables for each category, and event handlers keep the flow running when a mail is read, looted or deleted.
|
Sounds more like a coding error.
Attempt to index a nil value means exactly that.
You have a variable that is nil and your code wants to use it as a table, but you can't search through a nil value.
In example:
myobj:myfunc("bla")
If you get this error in that line, it means myobj is actually nil, not the table/object you expected. Because myobj is nil, it can't search myobj to find myfunc and so it throws the error.
So if your code is
myobj = SomeFunc()
myobj:myfunc("bla")
and you get the error in the myfunc line, then the problem is actually that SomeFunc() returns nil. You would need to figure out why SomeFunc returns nil then.
Next step:
myobj = SomeFunc(mailId)
myobj:myfunc("bla")
So, in this context it would mean mailId is invalid and as it is invalid, the function returns nil but the final crash happens a line later, because you try to actually use the nil object.
Most often the problem is also a simple typo:
mylongobj = SomeFunc(mailId)
...
mylongojb:myfunc("bla")
mylongojb doesn't exist.
HTH