Ralgathor / LibClassicSwingTimerAPI

GNU General Public License v3.0
4 stars 5 forks source link

Move initialization logic to PLAYER_ENTERING_WORLD, don't process events until initialization #46

Closed Korbrawr closed 1 year ago

Korbrawr commented 1 year ago

Currently, if the addon is loaded as an embedded library, ADDON_LOADED does not fire with the name of LibClassicSwingTimerAPI as the game considers the library to be loaded as part of the parent addon.

This causes problems as self.player and self.target are only initialized in ADDON_LOADED for version 2.0.1.

This PR puts the initialization back in PLAYER_ENTERING_WORLD, and adds a has_initialized variable, so the library won't process CLEU events until PLAYER_ENTERING_WORLD occurs.

After these changes, the addon works properly as an embedded library.

Korbrawr commented 1 year ago

I'm closing this since there's a better way to do the same thing - when loaded as a library, the addon that loaded the library is passed into the arguments of the .lua file (...), and we can use that to determine if ADDON_LOADED is for this addon or not.