WoWInterface - View Single Post - How to send arguments in OnEvent?
View Single Post
11-07-20, 05:29 PM   #2
I did that?
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,417
The arguments (payload) part of OnEvent is the ...
It means a variable number of arguments (each event has zero to lots or arguments depending on the event received)

Lua Code:
  1. Frame:SetScript("OnEvent", function(self, event, ...)
  2.     local arg1, arg2, arg3 = ...
  3.     print(arg1, arg3)
  4. end)

You can see for the PLAYER_ENTERING_WORLD event, it contains two arguments in its payload, isInitalLogin and isReloadUI so you could:

Lua Code:
  1. Frame:SetScript("OnEvent", function(self, event, ...)
  2.     if event == "PLAYER_ENTERING_WORLD" then
  3.         local isInitalLogin, isReloadUI = ...
  4.     elseif event == "BAG_OPEN" then
  5.         local bagID = ...
  6.     end
  7. end)
  8. Frame:RegisterEvent("PLAYER_ENTERING_WORLD")
  9. Frame:RegisterEvent("BAG_OPEN")
for example, to make it more readable what the arguments are for a particular event.
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 11-07-20 at 05:58 PM.
  Reply With Quote