View Single Post
08-22-14, 02:19 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
A few problems with your code that should be raising errors in-game:
  • You misspelled "EditMacro" as "EditMarco".
  • You're referring to a variable "index" which you don't define anywhere.

Other than that you're definitely on the right track. I'd suggest checking for InCombatLockdown() before proceeding with anything else in the event handler, just in case. I'd also use some nice variables at the top to contain the desired macro name and template, so it's easier to customize them, eg.

Code:
local MACRO_NAME = "FocusHealer"
local MACRO_BODY = "/focus [@arena%d]"
Then in your event handler you can pass the desired text as "string.format(MACRO_BODY, i)". You can also just pass the macro name to EditMacro instead of an index; I'd suggest doing that for the sake of simplicity and avoiding an extra function call.

Finally, go get BugSack. The default error display, even if you have it enabled, is simply not good enough for addon development, as it is incapable of showing errors that occur early in the loading sequence -- and that's where most of your errors will occur during development. Being able to see the error messages your code is raising is invaluable, as the message will tell you exactly what the problem is, and exactly where in your code it is.
__________________
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