View Single Post
01-13-13, 05:49 PM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1) If you're going to post code, post the entire code. Your snippets are obviously incomplete, as they refer to variables -- such as self and buffs -- that are not defined in anything you posted, and appear to be responding to events that are not registered. Especially when you're trying to help someone who says they've never written Lua before, posting only random snippets is more confusing than helpful.

2) You shouldn't use UNIT_AURA to detect shapeshift forms on the player. There is a dedicated event for that -- UPDATE_SHAPESHIFT_FORM.

3) Things like "ex" are not good choices for variable names. Addons are not macros; you don't need to condense everything to save space. Use a descriptive variable name like "expirationTime" that clearly describes its contents without needing to read the whole function to figure it out.

4) You should never call RunScript in an addon. Just write the code you want to run.

5) You should never specify a specific language with SendChatMessage -- like "Common" -- unless you have a specific purpose for doing so (such as in a role-playing addon) and you are checking the player's faction to pass the appropriate language. Your code, for example, will fail for Horde players, since they cannot speak Common. Instead, you should pass nil, which will cause the message to be sent in the player's default language.
__________________
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