Originally Posted by Elkano
I just downloaded the addon in order to have a look at your code since I have written such an addon, too (can be found ad eg curse: bags and merchants).
I noticed that you have a lot of code that isn't needed (anymore since the addon is dated back to April 05). Just a few examples how you could improve your code:
- use SavedVariablesPerCharacter instead of SavedVariables. So you won't have to mess with obtaining the characters name
- use the functions OpenAllBags and CloseAllBags which are already built into WoW.
- extrending to auction house or trade is only hooking two more events each
|
Thanks for the feedback Elkano!
I did consider revisiting all my existing code for the SavedVariablesPerCharacter feature, but in the end decided that unless I was writing a new addon that it wouldn't save that much, and I'd have had to figure out how to migrate any existing settings, etc. And in the more complex addons, I needed the player's name anyway. Of course it would be easier for users since all their settings for their own characters would be in one place
.
I didn't use OpenAllBags and CloseAllBags because I wanted Merchantbags to know which bags you already had open, and not close those when it closes the ones it opened itself.
Adding auction house and trade events might be useful additions next time I make a change to Merchantbags.
(Merchantbags is one of my earliest addons, and probably could be streamlined a bit - I'm a bit surprised at how popular it is!
)