Again, register for your callback in the main chunk (top level) of the addon. You can still wait for whenever you want to actually do everything else in your addon.
Lua Code:
local function AddonInitialization()
--do stuff that I
--have to wait until
--now to do
end
EVENT_MANAGER:RegisterEvent(EVENT_PLAYER_READY, AddonInitialization)
In the above example, the last line is in the main chunk of your addon - it is not wrapped within a function, or an if-then block, or a do-end, block, etc. You can do anything you want in the main chunk of your addon, so long as it doesn't depend on other things. In the ESOutpost addon, I create the *entire GUI* in the main chunk of the GUI.lua file. The only reason to do this...
Lua Code:
local function MyFunc()
--do stuff
end
MyFunc()
...is if you want to be able to call that function again later, for example. (Or if you want to isolate something in that scope, but you could also enclose that in a do-end block...)
So, again... In the main chunk of your addon, register for the "FTC_Ready" callback. It can go anywhere in the file, so long as it's after the function you want it to call was defined.
Lua Code:
local function FCTReadyCallback()
--do stuff now that FTC is done
end
CALLBACK_MANAGER:RegisterCallback("FTC_Ready", FCTReadyCallback)
local function AddonInitialization()
--do stuff that I
--have to wait until
--now to do
end
EVENT_MANAGER:RegisterEvent(EVENT_PLAYER_READY, AddonInitialization)
/edit: or even this:
Lua Code:
local function CreateSubmenu()
--do stuff now that FTC is done
end
local function AddonInitialization()
--do other stuff that I
--have to wait until
--now to do
CreateSubmenu()
end
CALLBACK_MANAGER:RegisterCallback("FTC_Ready", AddonInitialization)