View Single Post
04/23/14, 01:25 PM   #5
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
Let's compare methods between WoW and ESO so that you can get your bearings.

In WoW:
Lua Code:
  1. local f = CreateFrame("Frame", nil, UIParent)
  2. f:RegisterEvent("ADDON_LOADED")
  3. f:SetScript("OnEvent", function(self, event, addon)
  4.      if addon == "MyAddon" then
  5.           --do stuff
  6.      end
  7. end)

In ESO:
Lua Code:
  1. local f = CreateTopLevelWindow("MyAddonFrame")
  2. f:RegisterForEvent(EVENT_ADD_ON_LOADED, function(event, addon)
  3.      if addon == "MyFrame" then
  4.           --do stuff
  5.      end
  6. end)

or, you can do it this way in ESO (register your event through the game's EVENT_MANAGER instead of through a frame)
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("MyAddon", EVENT_ADD_ON_LOADED, function(event, addon)
  2.      if addon == "MyAddon" then
  3.           --do stuff
  4.      end
  5. end)

As you can see, both WoW and ESO pass the event name/code through the event handler before the args that come with the event.
  Reply With Quote