1. #1

    Need help identifying problem with lua error

    I 'created' my own addon at the beginning of the year by taking snippets from here and there, with basically no knowledge of lua. I still have really no knowledge of lua and I'd like some help if solving the error my addon is giving since 4.0.

    This is the error:
    Code:
    Message: [string "FishFeastAlertFrame:OnLoad"]:2: attempt to index global 'this' (a nil value)
    Time: 12/06/10 20:53:51
    Count: 1
    Stack: [string "*:OnLoad"]:2: in function <[string "*:OnLoad"]:1>
    
    Locals: self = FishFeastAlertFrame {
     0 = <userdata>
    }
    (*temporary) = nil
    (*temporary) = nil
    (*temporary) = <function> defined @Interface\AddOns\FishFeastAlert\FishFeastAlert.lua:95
    (*temporary) = "attempt to index global 'this' (a nil value)"
    You can grab the code here: http://wow.curse.com/downloads/wow-a...eastalert.aspx

    I can see roughly whats wrong but just can't see any way to fix it. Since it's a lot of code snippets I'm not positive on whats going on in places and would like some help please.
    Last edited by Toez; 2010-12-06 at 08:01 AM.

  2. #2
    Old:
    Code:
    FishFeastAlertFrame:OnLoad();
    
    function FishFeastAlertFrame:OnLoad()
    ('this' can be used as a reference without specifying it)
    ...
    end
    New:
    Code:
    FishFeastAlertFrame.OnLoad(self);
    
    function FishFeastAlertFrame.OnLoad(self)
    ('this' is no longer available, the first argument is the reference to the object and must be passed as a parameter)
    ...
    end
    I forgot to point out '.' vs ':' when declaring/calling functions in a table. See: http://en.wikipedia.org/wiki/Lua_%28...ng_language%29 > Object-oriented programming section
    Last edited by Woogs; 2010-12-06 at 08:19 AM. Reason: link

  3. #3
    Quote Originally Posted by Woogs View Post
    Old:
    Code:
    FishFeastAlertFrame:OnLoad();
    
    function FishFeastAlertFrame:OnLoad()
    ('this' can be used as a reference without specifying it)
    ...
    end
    New:
    Code:
    FishFeastAlertFrame.OnLoad(self);
    
    function FishFeastAlertFrame.OnLoad(self)
    ('this' is no longer available, the first argument is the reference to the object and must be passed as a parameter)
    ...
    end
    Would be easy if
    Code:
    FishFeastAlertFrame:OnLoad()
    was there but all of the functions are like
    Code:
    On Load = function () --Minus the space, couldn't post it without the space.
    I'll try to fix all of the functions if I get time I guess.
    Last edited by Toez; 2010-12-06 at 08:27 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •