On a second thought, I could use a little hint or two.
Right now, I have everything in a single file. Which, quite unsurprisingly, grow "a little" unwieldy.
I plan to separate stuff into more manageable chunks. However, the order of execution is important.
Right now, the code is laid like this:
Main addon frame (listener) is created right away, along with events table.
Then some additional stuff happens, that is not relevant to anything at this point.
Then events table is populated by callback functions, one per event. Like,
Code:
function events:PLAYER_ENTERING_WORLD(...) … end
…and all the things are written inside.
Then the callbacks are registered as listeners. Like the usual
lua Code:
for eventName, eventFunc in pairs(events) do
-- Register all events for which handlers have been defined
frame:RegisterEvent(eventName)
end
The problem as I see it is I can no longer registed events right away in the main block. I need to postpone them. May be I should hook some event that is fired very early first, and do the registration there? Which event, if that is a good idea?
P.S.
I plan to use
Code:
local addonName, addon = ...
and pass the data structures inside the "local-global" "addon" table, so that is not an issue.