View Single Post
04-26-14, 10:20 PM   #47
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by cokedrivers View Post
... not sure why but the petstancebutton needs for i=1, NUM_SLOTS, 1 do which the other 2 do not ...
You don't. There is literally no difference whatsoever between "for i = 1, 10 do" and "for i = 1, 10, 1 do".

Also:

While it doesn't really matter, you should use variable names that make sense. A variable like "buttonName" should logically contain the name of a button, not the button object itself.

Rather than doing more string concatenations and global lookups )eg. _["ThisBarButton"..i.."Icon"]) you should use the keys on the button that already point to those things (eg. button.icon).

Don't forget to call ClearAllPoints before you start calling SetPoint -- otherwise you may end up with unexpected results if the original region was positioned with points other than the ones you're setting.

Avoid duplicating code. If you're going to use the same chunk of code in 5 different places, factor it out into a function, and just call the function from those 5 places.

http://pastebin.com/WEGEz70y
__________________
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