WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   a nil value (like must issues) (https://www.wowinterface.com/forums/showthread.php?t=36453)

DonCorneo 11-01-10 08:07 AM

a nil value (like must issues)
 
Reported by Bug Grabber:

1x sfbs-4.0.0.0\sfbs.lua:15: attempt to index local 'self' (a nil value)
sfbs-4.0.0.0\sfbs.lua:150: in function `OnEvent'
<string>:"*:OnEvent":1: in function <[string "*:OnEvent"]:1>

Locals:
self = nil
checkshown = <function> @ sfbs\sfbs.lua:19:
RegEvents = <function> @ sfbs\sfbs.lua:13:
Update = <function> @ sfbs\sfbs.lua:85:

---


I have tried to make the changes from "this" to "self", but something is not right, obviously. I am still learning how all this works.
I'm not the original author, but have been handed the reins. The addon is SleekFreeBagSlots (aka sfbs and FreeBagSlots). Any help will be much appreciated. If another author wants to see what I've tried doing, PM me and let me know how to send the current .lua I'm working with.

Thank you very much!

Ailae 11-01-10 08:43 AM

You can paste code at www.pastebin.com or www.pastey.net for example.

But if the code used to be something like

lua Code:
  1. myframe:SetScript("OnEvent", function()
  2.     this:SetAwesomeStuff()
  3. end)

and you only changed the "this" to "self" it wont work, you also need to have it in the function call, like this (added some other stuff that would be relevant as well, such as 'event')

lua Code:
  1. myframe:SetScript("OnEvent", function(self, event)
  2.     self:SetAwesomeStuff()
  3. end)

But paste the code or no one can really help you properly.

Luzzifus 11-01-10 08:45 AM

You have to explicitly add "self" to the function header as the first parameter. Like:

lua Code:
  1. function OnEvent(self, event, ...)
  2.    -- here you can do things with self
  3. end

**edit: too late :(

DonCorneo 11-01-10 01:14 PM

Used http://www.pastey.net/142333 to post the original pre-Cataclysm .lua that was not throwing errors before 4xxx.
The addon is working still, but have to toggle "Global" off and on again to make it display, but it is not updating on its own like it should either.
Right now I just want to get it to stop throwing errors, than I'll work on the updating.


All times are GMT -6. The time now is 06:06 AM.

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