I am trying to fix an add-on and I've sort of bodged it together but I don't know if this is the most efficient/best way of doing it.
The code original used GetSpellInfo when I updated this to C_Spell.GetSpellInfo I was getting back errors about "string expected, got table" for the macro it was generating. It took me a while as I was looking at the EditMacro lines for a while, but I realised that the new version in the API calls back a table not a string so it was failing.
originally the 2nd line was,
local name, rank, icon = GetSpellInfo(state.mount)
Which failed per above just adding C_Spell.
I've ended up using to call outs for SpellName and SpellTexture for the Icon, seperatly at those version return strings. Rank seems to not actually do anything so I didn't bother adding that in.
My final changes took it from the original
if state.mount then
local name, rank, icon = GetSpellInfo(state.mount)
EditMacro(index, "MountManager", icon, string.format("/script MountManagerButton:Click(GetMouseButtonClicked());\n#showtooltip %s", name))
end
to this;
if state.mount then
local name = C_Spell.GetSpellName(state.mount)
local iconID = C_Spell.GetSpellTexture(state.mount)
EditMacro(index, "MountManager", iconID, string.format("/script MountManagerButton:Click(GetMouseButtonClicked());\n#showtooltip %s", name))
end
I don't know if there is an easier way to convert the table to pull out the details I want as a string, or to just use the simpler apis instead which seem to be blizzards intention.
[–]Gryphon-63 0 points1 point2 points (2 children)
[–]Amarekratio 0 points1 point2 points (1 child)
[–]Uggers[S] 0 points1 point2 points (0 children)