ruk·si

🌙 WoW API
Events

Updated at 2015-01-17 00:56

Event system is a bit silly and relies on manipulation of global variables like event and arg1. Your frames and other UI elements register for events and provide a handler.

local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN")
frame:SetScript("OnEvent", function()
    if event == "PLAYER_LOGIN" then
        print("Logged in!")
        -- if event has more info, you find them in arg1, arg2, etc.
    end
end)