WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   help with ContinueOnSpellLoad (https://www.wowinterface.com/forums/showthread.php?t=56310)

Taet 06-25-18 10:55 AM

help with ContinueOnSpellLoad
 
I using GetSpellDescription in legion without any problems, now blizzard change this function and must by called with ContinueOnSpellLoad, but dont work any help me.

me previous (legion) code:
Lua Code:
  1. spell_desc = {
  2.                 type = 'description',
  3.                 fontSize = 'medium',
  4.                 order = 3.3,
  5.                 name = function(info)
  6.                         return GetSpellDescription(spellID)
  7.                 end,
  8.             },

me BFA code (dont work, no bugs report only dont show any):
Lua Code:
  1. spell_desc = {
  2.                 type = 'description',
  3.                 fontSize = 'medium',
  4.                 order = 3.3,
  5.                 name = function(info)
  6.                     local spell = Spell:CreateFromSpellID(spellID);
  7.                     spell:ContinueOnSpellLoad(function()
  8.                     return GetSpellDescription(spell:GetSpellID())
  9.                     end);
  10.                 end,
  11.             },

Xrystal 06-25-18 02:46 PM

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] = {}
  4.    
  5.     local id,fileID = GetSpellTexture(spellID)
  6.     local name = GetSpellInfo(spellID)
  7.     local isKnown = IsSpellKnown(spellID)
  8.    
  9.     addonData.SpellCache[spellID].TextureID = fileID    
  10.     addonData.SpellCache[spellID].Name = name
  11.     addonData.SpellCache[spellID].isKnown = isKnown
  12.    
  13. end

Taet 06-27-18 11:33 AM

ty, i try this, when i select dungeon, i directly call GetSpellDescription for all spellID in database:
Lua Code:
  1. set = function(info, value)
  2.                     selectedDungeon = value;
  3.                     local mapID = selectedDungeon and match(selectedDungeon, "(%d+)")
  4.                     if mapID then mapID = tonumber(mapID) end
  5.                     for i,v in pairs(L.MythicSpellData[mapID]) do
  6.                         GetSpellDescription(i)
  7.                     end  
  8.                     L.UpdateSpellDatabase()
  9.                 end,

and in another code i take 100% correct answer when call GetSpellDescription(spelID), dont need ContinueOnSpellLoad.


sry for eng.


All times are GMT -6. The time now is 05:39 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI