function Zorlen_TogglePetSpellAutocast(SpellName, mode)
local m = nil
if not (UnitHealth("pet") > 0) then
Zorlen_debug("Your pet is not active or alive to use pet ability: "..SpellName)
return false
end
for i=1, NUM_PET_ACTION_SLOTS, 1 do
local slotspellname, slotspellsubtext, texture, isToken, isActive, autoCastAllowed, autoCastEnabled = GetPetActionInfo(i)
if (slotspellname and slotspellname == SpellName) then
if (mode == "on") then
if not autoCastEnabled then
TogglePetAutocast(i)
return true
end
elseif (mode == "off") then
if autoCastEnabled then
TogglePetAutocast(i)
return true
end
else
TogglePetAutocast(i)
return true
end
end
end
Zorlen_debug("Unable to locate pet ability: "..SpellName)
return false
end
(ref: http://addons.us.to/addon/zorlen-0 file "Zorlen_Pets.lua")
Use:
Zorlen_TogglePetSpellAutocast("Firebolt", "on")