diff --git a/TacoTip.toc b/TacoTip.toc index a764963..3ce2d2a 100644 --- a/TacoTip.toc +++ b/TacoTip.toc @@ -1,5 +1,5 @@ ## Interface: 11304 -## Version: 0.2.1 +## Version: 0.2.2 ## Title: TacoTip ## Notes: TacoTip (GearScore & Talents) ## Author: kebabstorm diff --git a/gearscore.lua b/gearscore.lua index 86dfd27..bc1d088 100644 --- a/gearscore.lua +++ b/gearscore.lua @@ -211,7 +211,7 @@ local function itemcacheCB(tbl, id) end -function TT_GS:GetScore(unitorguid, callbackFunc) +function TT_GS:GetScore(unitorguid, useCallback) local guid = getPlayerGUID(unitorguid) if (guid) then if (guid ~= UnitGUID("player")) then @@ -235,7 +235,7 @@ function TT_GS:GetScore(unitorguid, callbackFunc) local cb_table - if (callbackFunc) then + if (useCallback) then cb_table = {["guid"] = guid, ["items"] = {}} end @@ -244,14 +244,16 @@ function TT_GS:GetScore(unitorguid, callbackFunc) mainHandLink = mainHandItem:GetItemLink() else IsReady = false - if (callbackFunc) then - local id = mainHandItem:GetItemID() - table.insert(cb_table.items, id) - mainHandItem:ContinueOnItemLoad(function() - itemcacheCB(cb_table, id) - end) - else - C_Item.RequestLoadItemDataByID(mainHandItem:GetItemID()) + local itemID = mainHandItem:GetItemID() + if (itemID) then + if (useCallback) then + table.insert(cb_table.items, itemID) + mainHandItem:ContinueOnItemLoad(function() + itemcacheCB(cb_table, itemID) + end) + else + C_Item.RequestLoadItemDataByID(itemID) + end end end end @@ -260,14 +262,16 @@ function TT_GS:GetScore(unitorguid, callbackFunc) offHandLink = offHandItem:GetItemLink() else IsReady = false - if (callbackFunc) then - local id = offHandItem:GetItemID() - table.insert(cb_table.items, id) - offHandItem:ContinueOnItemLoad(function() - itemcacheCB(cb_table, id) - end) - else - C_Item.RequestLoadItemDataByID(offHandItem:GetItemID()) + local itemID = offHandItem:GetItemID() + if (itemID) then + if (useCallback) then + table.insert(cb_table.items, itemID) + offHandItem:ContinueOnItemLoad(function() + itemcacheCB(cb_table, itemID) + end) + else + C_Item.RequestLoadItemDataByID(itemID) + end end end end @@ -314,14 +318,16 @@ function TT_GS:GetScore(unitorguid, callbackFunc) LevelTotal = LevelTotal + ItemLevel else IsReady = false - if (callbackFunc) then - local id = item:GetItemID() - table.insert(cb_table.items, id) - item:ContinueOnItemLoad(function() - itemcacheCB(cb_table, id) - end) - else - C_Item.RequestLoadItemDataByID(item:GetItemID()) + local itemID = item:GetItemID() + if (itemID) then + if (useCallback) then + table.insert(cb_table.items, itemID) + item:ContinueOnItemLoad(function() + itemcacheCB(cb_table, itemID) + end) + else + C_Item.RequestLoadItemDataByID(itemID) + end end end end