1. Hey everyone :)

    I decided to surprise a friend by writing an addon for him regarding the eagle boss in Zul'Aman. The one with the small eagles coming down and attacking randomly, that one.

    What I would like is for him to have a button which will automatically shoot arcane shot at a bird. Now, I've been having some trouble with this. The smoothest way would be to code the button to shoot a spell at the birds, without targeting them. Like a macro can do with /cast [target=blabla] Arcane Shot. Of course, he could use that macro straight off and he'd be done but I've added some extra alerts and sounds just for kicks.

    I checked the book and searched here for some hints but came up empty-handed.

    The function 'CastSpellByName' would be perfect, too bad I can't use it (or am I wrong about this?).

    I then gave up and decided to just change target to a bird and then shoot when he clicked the button. Alas, using LUA to set a target gave me a 'addon has been blocked by Blizzard..' message, which is telling me I'm not doing it quite right.

    I tried setting the attributes manually in the xml file and later on in the LUA-code itself.

    Using the SAB-example found in the book, check this out: SABTest:SetAttribute("type", "spell") SABTest:SetAttribute("spell", "Arcane Shot") SABTest:SetAttribute("unit", "target")

    This works fine, however it does require you to have a target. I tried changing the last row's "target" to a variable or a specific mob I was close by when writing the addon itself. Neither options worked. Is it doable?

    Does anyone have a few tips & tricks regarding this issue? Setting a target, or better yet just casting a spell at a specific mob without changing your target?

    It's doable with a macro type button.

    My bad, I had forgotten to add that I tried that option too.

    My code used was this, for testing: SABTest:SetAttribute("macrotext", "/cast [target=Frigid Owl] Arcane Shot")

    Target= can't be that kind of unit name; it uses identifiers like "mouseover" or "focustarget". The macro has to have a /target line to target something with a name.

    You can test it out as just a macro, and then when you have one that works insert it into your addon.

    (Edited because I haven't had enough tea yet today and didn't notice the issue at first glance.)

    Aye, thanks for the reply :)

    I messed about with the macro thingys a bit more and actually got it to work!

    Button1:SetAttribute("type", "macro") Button1:SetAttribute("macro", "BIRDS1")

    This of course demands I already have a macro written. I tried creating a macro within the LUA code itself but it didn't appear. I put it in the OnLoad-function, I don't know if that's right or not, but it seemed like a good place.

    I followed the example at http://wowprogramming.com/docs/api/CreateMacro and had this in my code: local index = CreateMacro("Yarr", 73, "/target Strigid Owl\n/cast Arcane Shot")

    It seems a bit vague though.. Did I do something wrong?

    It's better to use the macrotext attribute than the macro attribute so that you don't use up a macro slot. It's also simpler.

    Note that the macro attribute needs to not be used in that case, or macrotext will be ignored.

    There's an example of setting a secure button to execute a macro on page 295.

    Yes, thanks for the tip. I forgot I read that part earlier but chose to take another route.

    It seems to be broken now though =P

    Button1:SetAttribute("type", "macro") apparently needed to be there, otherwise nothing would happen at all.

    I even tried to include a smile in the macro to see if that part executed, which it didn't of course. All that happens when I press the button is that auto attacking starts, not a single arcane shot :( Button1:SetAttribute("macrotext", "/target Strigid Owl\n/cast Arcane Shot\n/smile")

    I don't notice any issues with that. If it were my addon that I were debugging, I'd add a print statement utilizing GetAttribute to check that the type and macrotext attributes are set the way you think they are.

    How much have you changed since it was working with a macro attribute?

    Haven't changed much so the change is easily reversible. I'll look into it tomorrow and try to figure out where it's bugging out!