View Single Post
01-10-07, 06:37 PM   #2
Flickerstreak
A Deviate Faerie Dragon
Join Date: Dec 2006
Posts: 19
CastSpellByName() works just fine for pet spells. At least, it used to: I haven't looked in awhile. You can easily test this out by targeting an enemy and typing the following in chat with your water elemental out:

Code:
/cast Freeze
(/cast just invokes CastSpellByName)

Of course, CastSpellByName() is now protected,, but you can invoke it indirectly via a button click with a frame derived from SecureActionButton as follows:

Code:
  frame:SetAttribute("type","spell") -- when clicked, cast a spell by name
  frame:SetAttribute("spell1","Freeze") -- spell1 = left button
  frame:SetAttribute("spell2","Water Bolt") -- spell2 = right button

  -- you can even mix and match pet and player spells on the same button:
  frame:SetAttribute("shift-spell1","Frost Nova") -- shift-spell1 = shift-leftbutton
You can bind a key to the button as follows (as long as the frame was created with a name):

Code:
SetBindingClick(key, frame:GetName(),"LeftButton") 
SetBindingClick(key, frame:GetName(),"RightButton")
In this case key is the key-press string (think it's just a single UTF-8 character) as passed to and OnKeyDown handler and possibly modified with a prefix, e.g. "1", "a", or "shift-q".

Then again, if you've tested it out, maybe CastSpellByName() isn't working for pet spells (in which case /cast isn't working for pet spells: I think we'd have heard a bit of an outcry from hunter and warlock macroers in that case).

Unless it's just the "Freeze" spell - previously I think it was called "Frost Nova (Water Elemental)" or something, in which case you actually have to use the name "Frost Nova (Water Elemental)()" to avoid it trying to interpret 'Water Elemental' as the rank of the spell and failing.

Last edited by Flickerstreak : 01-10-07 at 06:49 PM.
  Reply With Quote