View Single Post
04/24/15, 12:00 PM   #2
Adalan
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 20
Originally Posted by Baertram View Post
Hey there,

I just tried to use the event EVENT_ACTIVE_WEAPON_PAIR_CHANGED to see if the active weapon bar was changed.

1) It gets fired once with locked = true for the current active action bar (1) to lock it (but this does not happen always?).
2) Afterwards it gets fired for the new action bar (2) with locked = true.
3) And then finally it gets fired with the new action bar (2) and locked = false.

"Locked" means the small "lock symbol" at the action bar which says you cannot use or change the bar currently.

I just want to react on a player changing his action bar. But this chain of event firing will be ALWAYS fired with steps 2 and 3 if I even only use my attack skill of the weapon.
Bar gets locked 2), bar gets unlocked 3).

Any chance to filter this out so I can just react on a player "really" changing his action bars?

My current solution is:
-Upon login: Get active bar and save it into global addon variable
-Event is fired: Check if global variable differs from current event's active weapon pair id
-> As "locked = false" and weaponbar Id differs: Update the global variable with the new variable from the event

I only run my code if the last weapon bar id differs from the current one.

Any better solutions?

Thanks for your help.
If you check out the code of my maintained GearSwap, it show you, that i got exactly the same problems and solved that by alot of blocker routines with boolean, to stop running into those routines more than two times. Its not enough to just stop the EVENT, because you need it running sometimes for another check.
It was a horrible coding action, because alot of situations raised the swap-effect, where no swap was done. (like mounting up, changing maps, talking to vendors and so on)

Forget the lock - use your own boolean and maybe a counter to suppress running into your routines more than two times by those raised events.
Btw, the ID-Check is that, what ive done also in GearSwap and help you at least for some occouring events to stop that.

Greets,
Adalan

Last edited by Adalan : 04/24/15 at 12:26 PM.
  Reply With Quote