View Single Post
08-22-14, 05:57 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by melanorion View Post
Can you link addons (you know) wich have good practice in they code ? I'll go analyze bToolTip, but if there is no best practices topic, if not many addons are good, how can we start coding ? i find the list of ace3 lib and example of using it.
Haste, Tekkub, Industrial, Adirelle, Rabbit, Ammo all generally write good clean code, and obviously I'd recommend myself as well. :P Stick to smaller addons for general examples, as they'll be easier to understand and it'll be easier to ignore anything irrelevant. If you see a lot of select calls and semicolons and tables being created in functions, stay away.

I'd recommend learning how to write addons without using libraries first. That way you'll have a better understanding of how addons actually work, and then later you can make an informed decision about whether to use a library or not.

Originally Posted by melanorion View Post
Is there a topic which explain a generic skeleton addon ?
- How to init my addon
- Which event should i catch, why
- should i save data (savedVariable?), how, why
- it's an ui addon (skada for example), how manage frame / elements in frame
Use the ADDON_LOADED and/or PLAYER_LOGIN events to initialize your addon. When ADDON_LOADED fires with your addon's name as its first (and only) argument, that means that all of your addons files have been read, including its saved variables file(s). When PLAYER_LOGIN fires, that means that all information about your character is now available, including your GUID, talents, etc.

Whether or not you "should" save data seems like a pretty straightforward question to answer. If you want to save any data -- such as the position of a frame, the user's preferred font, a count of how many murlocs the player has killed, or any other information -- between sessions, save it. If you don't have any data to save, then you don't.

As for "managing frames" that's a pretty open-ended question. It really depends on what you want to do. If you want to show or hide a frame, show or hide a frame. If you want to show some text, create a font string and tell it what text to show. etc.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote