I have a personal addon that saves bars and also replace macro tabs (general become char macros and char macros become general macros) my solution for this problem is sketched bellow:
Lua Code:
--macros whose names are in the format PHxx where xx is between 00 and 99 are reserved for place holder macros
local ph_number = 0 --number of current place holder macros
local ph_list = {} --list of place holder macros; k: spell id; v:macro name
local Create_Place_Holder_Macro
--put this in the load loop of saved action bars, when you have a spell to this:
--in my version of action bar saver there is no cache, so the code will need some adaptation on this regard
PickupSpell(spell_id)
if GetCursorInfo()==nil then
if ph_list[spell_id]==nil then
ph_number = ph_number+1
ph_list[spell_id] = Create_Place_Holder_Macro(spell_id,ph_number)
end
PickupMacro(ph_list[spell_id])
end
--put this in the save loop of current action bars, when you have a macro to this to check if you have a place holder macro to save the spell:
if macro_name:match("^PH%d%d$") then
for k,v in pairs(ph_list) do
if v==macro_name then
local actionType = "spell"
local id = k
local name, spellRank = GetSpellInfo(id)
set[actionID] = string.format("%s|%d|%s|%s|%s|%d", actionType, id, "", name, spellRank or "", "")
break
end
end
end
function Create_Place_Holder_Macro(spell_id,ph_number)
local am = GetNumMacros()
local macro_name = "PH"..string_format("%02d",ph_number)
local spell_name,_,texture = GetSpellInfo(spell_id)
if texture then
if am<MAX_ACCOUNT_MACROS then
CreateMacro(macro_name,texture,"#showtooltip\n/cast "..spell_name)
return macro_name
end
end
end
--you need a way to detect that specialization has changed and when it happens you should delete all place holder macros
local function call_me_when_spec_changes()
if ph_number>0 then
for i=1,ph_number do
local macro_name = "PH"..string_format("%02d",i)
DeleteMacro(macro_name)
end
wipe(ph_list)
ph_number = 0
end
end
The basic idea is to put a macro with /cast spell when the spell can't be picked up.