1. Hey, I have some programming experience but I'm stuck with this one.  I'm trying to register an event directly through Lua, and the event is registered fine but the function never gets called.  What's wrong here:

    hidden = CreateFrame("Frame", nil, UIParent)

    hidden:RegisterEvent("UNIT_AURA")

    print("loaded")



    function hidden:OnEvent(event, ...)

    print("event hit")

    end

    The "loaded" appears fine, and I've used IsEventRegistered on UNIT_AURA and this is returning 1.  I'm obviously misunderstand how to link up the method to the Frame's OnEvent because it doesn't look like I've done that at all in the code but I'm lost as to how to do it.  Can you help?

  2. Always the way, you spend an ages on it and then work it out as soon as you give up and post on the forum!  So SetpScript was what I needed and I've got it to work like this:

    hidden = CreateFrame("Frame", nil, UIParent)
    hidden:RegisterEvent("UNIT_AURA")
    hidden:SetScript("OnEvent",
       function(self, event, ...)
          print("event hit")
       end
    )
    print("loaded")

    How would I get it to work if I wanted to have the function defined seperately?  Can I somehow pass the function name instead of defining the actual function inside the SetScript?  I can't get it to work this way around.

  3. Always the way, you spend an ages on it and then work it out as soon as you give up and post on the forum!  So SetpScript was what I needed and I've got it to work like this:

    hidden = CreateFrame("Frame", nil, UIParent)

    hidden:RegisterEvent("UNIT_AURA")

    hidden:SetScript("OnEvent",

    function(self, event, ...)

    print("event hit")

    end

    )

    print("loaded")

    How would I get it to work if I wanted to have the function defined seperately?  Can I somehow pass the function name instead of defining the actual function inside the SetScript?  I can't get it to work this way around.

    The equivalent to your code would look like:

    hidden = CreateFrame("Frame", nil, UIParent)

    hidden:RegisterEvent("UNIT_AURA")



    function myHandler(frame, event, ...)

    print("event hit")

    end



    hidden:SetScript("OnEvent", myHandler)

    print("loaded")

    This is good example of the concept of functions as variables. You can also rewrite the first line of the function as follows:

    myHandler = function(frame, event, ...)

  4. That looks like what I tried (it makes sense to me) but I guess I had a mistake somewhere, will try again later, thanks.

  5. This is working, thanks for the help :) .