Finally figured out the problem is due to the data table not being generated properly. I must be creating it at the wrong time in Beta and not doing it at all in Live. Manually setting the spell ID on the XML allowed the button click to cast the spell but no icon appearing ( likely due to the problem identified ). So back to tracing the execution route to make sure the right values are set at the right time rofl. Considering setting a full table at the start rather than smaller tables when requested.
Lua Code:
function addonData:GenerateSpellsPerMap()
local factionGroup, factionName = UnitFactionGroup("player")
local portalIdx = 1
local teleportIdx = 1
self.MapSpells = {}
DEFAULT_CHAT_FRAME:AddMessage("GenerateSpellsPerMap 1")
for i,v in pairs(self.Spells) do
local mapInfo = C_Map.GetMapInfo(v.map)
self.MapSpells[v.map] = self.MapSpells[v.map] or {}
local spell = Spell:CreateFromSpellID(i)
DEFAULT_CHAT_FRAME:AddMessage("GenerateSpellsPerMap 2 : " .. i)
spell:ContinueOnSpellLoad(function()
local spellName = GetSpellInfo(i)
local id,fileID = GetSpellTexture(i)
local idx = v.isPortal and portalIdx or teleportIdx
if v.faction == factionName or "Neutral" then
DEFAULT_CHAT_FRAME:AddMessage("Generating data for " .. i .. " : " .. spellName .. " : " .. fileID) -- Contains values
addonData.MapSpells[v.map].Spells = addonData.MapSpells[v.map].Spells or {}
addonData.MapSpells[v.map].Spells[i] = addonData.MapSpells[v.map].Spells[i] or {}
addonData.MapSpells[v.map].Spells[i].isPortal = v.isPortal
addonData.MapSpells[v.map].Spells[i].name = spellName
addonData.MapSpells[v.map].Spells[i].icon = fileID
addonData.MapSpells[v.map].Spells[i].buttonIdx = idx
if v.isPortal then
portalIdx = portalIdx + 1
else
teleportIdx = teleportIdx + 1
end
DEFAULT_CHAT_FRAME:AddMessage("GenerateSpellsPerMap 3 : " .. addonData.MapSpells[v.map].Spells[i].name) -- Contains value
end
end)
end
DEFAULT_CHAT_FRAME:AddMessage("GenerateSpellsPerMap 4 : " .. #addonData.MapSpells[addonData.activePage].Spells) -- attempt to index field error
end
Based on this latest debugging session it appears the new callback feature to ensure spell data is available also resets the data it sets when you leave, even on an addon wide data table. It is starting to look like I will have to use this function for every spell button that I want to set the spell data to. Hard coding the button attribute setting code to a specific value works ( without icon at the moment ) but trying to access the data value it has a hiccough ... more research, but getting closer.