View Single Post
05/26/14, 06:02 PM   #15
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
Originally Posted by Seerah View Post
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:
  1. local function QB_isEnabledInAvA()
  2.     if IsPlayerInAvAWorld() then return QB_vars.isEnabledInAvA
  3.     --QB_vars.isEnabledInAvA is saved variable, aka user choice
  4.     else return true end
  5. end
  6.  
  7. local function QB_RegisterEvents_OnActivated()
  8.     --QB_internal.eventsInitialized is a variable to avoid registering same stuff over and over
  9.     if QB_isEnabledInAvA() and not QB_internal.eventsInitialized then QB_internal.eventsInitialized = true
  10.     --if not registered, check if features are enabled in Cyrodiil, if it is enabled or player is not in Cyrodiil, register stuff
  11.         registerStuff()
  12.     elseif not QB_isEnabledInAvA() and QB_internal.eventsInitialized then QB_internal.eventsInitialized = false
  13.     --if stuff are registered, check if features are enabled in Cyrodiil, if it is not enabled there then unregister stuff
  14.         unregisterStuff()
  15.     else return end
  16.     --if stuff are not registered, and features are disabled in Cyrodiil, do not register anything in there
  17. end

Last edited by lyravega : 05/26/14 at 06:42 PM.
  Reply With Quote