WoWInterface - View Single Post - help with ContinueOnSpellLoad
View Single Post
06-25-18, 02:46 PM   #2
nUI Maintainer
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,487
This is what I ended up doing for my Mage Portal addon. It might not work for your use but thought I would put it out there to see if it works for you. I recall trying the one you did and it seemed to be intermittent in its use so tried this route and so far it hasn't failed me once I cached the results.

OnEvent Script function contents
Lua Code:
  1. if event == "PLAYER_ENTERING_WORLD" then
  2.         for i,v in pairs(addonData.Spells) do
  3.             C_Spell.RequestLoadSpellData(i)
  4.         end        
  5.     elseif event == "SPELL_DATA_LOAD_RESULT" then
  6.         local spellID,success = ...
  7.         if success and addonData.Spells[spellID] then
  8.             CacheSpellData(spellID)
  9.         end
  10.     end

In my case I have a preset list of spellID's I am interested in so I grab and store when the addon first loads but you can call that RequestLoadSpellData(spellID) function at any point and then watch for it and act according with the other event.

CacheSpellData is a function that stores the data i need to keep for the duration of the addon as for some reason it seems to disappear after a while. I guess the if you snooze you lose scenario.

Lua Code:
  1. local function CacheSpellData(spellID)
  2.     addonData.SpellCache = {}
  3.     addonData.SpellCache[spellID] = {}
  5.     local id,fileID = GetSpellTexture(spellID)
  6.     local name = GetSpellInfo(spellID)
  7.     local isKnown = IsSpellKnown(spellID)
  9.     addonData.SpellCache[spellID].TextureID = fileID    
  10.     addonData.SpellCache[spellID].Name = name
  11.     addonData.SpellCache[spellID].isKnown = isKnown
  13. end
  Reply With Quote