I have never used merc mode, but I'm going to guess that
UNIT_FACTION would fire with arg1="player". You might also be able to try
SPELLS_CHANGED?
For your fall-back question.... here is a solution that lets you use as many spells as you want.
Lua Code:
-- list any spell here; doesn't even have to be your class -- doesn't even have to be real!
local spellsInPriorityOrder =
{
"Ultimate Rogue-Slaying Greater Pyroblast!",
"Combustion",
"Arcane Intellect",
"Thoughtsteal",
"Shadowfiend",
"Power Word: Fortitude",
"Auto Attack", -- fallback for other classes
}
-- %s will be replaced by the name of the spell
local macroPattern = [=[#showtooltip
/cast %s]=]
local function updateMacro()
for __, spellName in ipairs(spellsInPriorityOrder) do
if (GetSpellInfo(spellName)) then
EditMacro("myFavouriteMacro", nil, nil, macroPattern:format(spellName))
break
end
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_PVP_TALENT_UPDATE")
f:RegisterEvent("PLAYER_LOGIN")
f:RegisterEvent("UNIT_FACTION")
f:SetScript("OnEvent", function(event, arg1)
if (event ~= UNIT_FACTION or arg1 == "player") then
updateMacro()
end
end)