Originally Posted by Seerah
And what happens when another addon wants to register for that event and only uses "QB"?
|
I am not aware of any other add-on that has a name with two words that start with Q and B, but I'll change those to avoid conflict and stuff nonetheless.
As for my problem, the solution looks ugly. Very ugly in fact. But functionality wise, it is much better than doing the checks on handler functions. I just hope I didn't miss anything - I just hope it won't register same stuff over and over.
If anyone is interested, this is the solution that I come up with:
Lua Code:
local function QB_isEnabledInAvA()
if IsPlayerInAvAWorld() then return QB_vars.isEnabledInAvA
--QB_vars.isEnabledInAvA is saved variable, aka user choice
else return true end
end
local function QB_RegisterEvents_OnActivated()
--QB_internal.eventsInitialized is a variable to avoid registering same stuff over and over
if QB_isEnabledInAvA() and not QB_internal.eventsInitialized then QB_internal.eventsInitialized = true
--if not registered, check if features are enabled in Cyrodiil, if it is enabled or player is not in Cyrodiil, register stuff
registerStuff()
elseif not QB_isEnabledInAvA() and QB_internal.eventsInitialized then QB_internal.eventsInitialized = false
--if stuff are registered, check if features are enabled in Cyrodiil, if it is not enabled there then unregister stuff
unregisterStuff()
else return end
--if stuff are not registered, and features are disabled in Cyrodiil, do not register anything in there
end