View Single Post
01-23-21, 09:59 AM   #7
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
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:
  1. -- list any spell here; doesn't even have to be your class -- doesn't even have to be real!
  2. local spellsInPriorityOrder =
  3. {
  4.     "Ultimate Rogue-Slaying Greater Pyroblast!",
  5.     "Combustion",
  6.     "Arcane Intellect",
  7.     "Thoughtsteal",
  8.     "Shadowfiend",
  9.     "Power Word: Fortitude",
  10.     "Auto Attack"-- fallback for other classes
  11. }
  12.  
  13. -- %s will be replaced by the name of the spell
  14. local macroPattern = [=[#showtooltip
  15. /cast %s]=]
  16.  
  17. local function updateMacro()
  18.     for __, spellName in ipairs(spellsInPriorityOrder) do
  19.         if (GetSpellInfo(spellName)) then
  20.             EditMacro("myFavouriteMacro", nil, nil, macroPattern:format(spellName))
  21.             break
  22.         end
  23.     end    
  24. end
  25.  
  26. local f = CreateFrame("Frame")
  27. f:RegisterEvent("PLAYER_PVP_TALENT_UPDATE")
  28. f:RegisterEvent("PLAYER_LOGIN")
  29. f:RegisterEvent("UNIT_FACTION")
  30. f:SetScript("OnEvent", function(event, arg1)
  31.     if (event ~= UNIT_FACTION or arg1 == "player") then
  32.         updateMacro()
  33.     end
  34. end)

Last edited by DahkCeles : 01-23-21 at 10:04 AM. Reason: Tabs/whitespace
  Reply With Quote