MyFirstAddon

Apr 20, 2009 at 4:19 AM
Edited Apr 20, 2009 at 4:35 AM
I know, I know, Im a big noob. I am atempting to create an addon by following the steps in Chapter 14 of "World of Warcraft Programming". I'm having trouble with the code in the lua. The frame loads just fine and I can close the frame using the button but the onload function is returing an error when the addon loads and for the life of me I don't see why. This is the code

 function helloWordFrame_OnLoad()
    frame:RegisterEvent("PLAYER_TARGET_CHANGED"); -- this is line 5
end

function helloWordFrame_OnEvent()
      if (event == "PLAYER_TARGET_CHANGED") then
              if UnitExists("target") then
                   addonMessage:SetText("Hello " .. UnitName("target") .. "!");
              end
     end
end

function closeButton_OnClick()
     helloWordFrame:Hide()
end

the error I'm getting is:
 Error: attempt to index local 'frame' (a nil value)
WHY?!?!

Apr 21, 2009 at 2:34 AM
How about this:

function helloWordFrame_OnLoad()
    self:RegisterEvent("PLAYER_TARGET_CHANGED"); -- this is line 5
end

Note, frame: to self: ?
May 30, 2009 at 7:24 PM

I had the same damn problem.  I am finding that the book is a big waste of cash.  It is peraching to noobs, but how are we supposed to know the difference between an error made trying to copy the book or an error in the book.

Aug 16, 2009 at 5:13 PM

You have to make a frame, make sure it's selected, then open theproperties widow, at the botton of the list it should say "Frame1" in one feild at the botton, click on it and name it "helloWorldFrame"

 

Also:

make sure you have al components needed in your addon