View Single Post
11-08-20, 03:58 AM   #4
lungdesire
A Deviate Faerie Dragon
Join Date: May 2020
Posts: 13
Thanks, but how send "hello" and "bye" from the loop in OnEvent?

Originally Posted by Fizzlemizz View Post
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.
  Reply With Quote