View Single Post
07/07/17, 06:37 AM   #11
haggen
 
haggen's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 137
Originally Posted by rewt3498 View Post
Of course it is. I'm grateful for any help you are able to give whenever!

Edit: I have arrived at a solution thanks to what Rhyono said earlier. I found some information about registering for add on loaded event and combined it with zo_callLater, and I now have a working script. Thanks everyone.
zo_callLater is sloppy, should be avoided for this kind of situation if possible.

Now about the AddOnLoaded event, you should ALWAYS wait it to be fired to begin your actual modifications. You can prepare stuff outside, set tables, define functions, but only actually do something after it's triggered. i.e.

Lua Code:
  1. local function DoSomethingCrazy()
  2.     -- Here I'm goin nuts!
  3. end
  4. EVENT_MANAGER:RegisterForEvent("BonkersAddOn", EVENT_ADD_ON_LOADED, function(eventCode, addOnName)
  5.     if (addOnName == "BonkersAddOn") then
  6.         DoSomethingCrazy()
  7.     end
  8. end)
  Reply With Quote