Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function FARaidTools:itemCache(itemLink)
- if debugOn then print("cacheItem(): Item info for item "..itemLink.." requested from server.") end
- if #table_itemQuery == 0 then
- table.insert(table_itemQuery, GetTime()+(cacheInterval/1000)) -- add a time so that onupdate knows when to check if the data is ready yet
- end
- table.insert(table_itemQuery, itemLink) -- add to the query queue
- end
- function FARaidTools:itemAdd(itemLink)
- if not GetItemInfo(itemLink) then -- check if the item needs to be cached
- FARaidTools:itemCache(itemLink) -- we don't have item data so we have to cache the item
- return -- itemAdd will be called again via onUpdate once it's ready
- -- potential problem here if this code triggers from onUpdate, but it shouldnt
- end
- local id
- for i=1,#table_mainData do
- local match = string.match(table_mainData[i]["cols"][1]["value"], hyperlinkPattern)
- if match == nil then
- print("Error: match returned nil. i="..i)
- DevTools_Dump(table_mainData[i])
- return
- end
- local link1 = stripItemData(match)
- local link2 = stripItemData(itemLink)
- if link1 == link2 then
- id = i
- if debugOn then print("addToLootWindow(): Found match in data table. ID #"..id) end
- break
- end
- end
- if id then
- local quantity = tonumber(string.match(table_mainData[id]["cols"][1]["value"], "x(%d+)$")) or 1
- table_mainData[id]["cols"][1]["value"] = string.match(table_mainData[id]["cols"][1]["value"], hyperlinkPattern).."x"..tostring(quantity+1)
- else
- table.insert(table_mainData, {
- ["cols"] = {
- {
- ["value"] = itemLink,
- ["args"] = nil,
- ["color"] = {
- ["r"] = 1.0,
- ["g"] = 1.0,
- ["b"] = 1.0,
- ["a"] = 1.0,
- },
- ["colorargs"] = nil,
- ["DoCellUpdate"] = nil,
- },
- {
- ["value"] = "30",
- ["args"] = nil,
- ["color"] = {
- ["r"] = 0.5,
- ["g"] = 0.5,
- ["b"] = 0.5,
- ["a"] = 1.0,
- },
- ["colorargs"] = nil,
- ["DoCellUpdate"] = nil,
- },
- {
- ["value"] = "",
- ["args"] = nil,
- ["color"] = {
- ["r"] = 1.0,
- ["g"] = 1.0,
- ["b"] = 1.0,
- ["a"] = 1.0,
- },
- ["colorargs"] = nil,
- ["DoCellUpdate"] = nil,
- },
- },
- ["color"] = {
- ["r"] = 1.0,
- ["g"] = 0.0,
- ["b"] = 0.0,
- ["a"] = 1.0,
- },
- ["colorargs"] = nil,
- ["DoCellUpdate"] = nil,
- })
- end
- FA_RTscrollingtable:SetData(table_mainData, false)
- FARaidTools:generateIcons()
- if not FA_RTframe:IsShown() then
- if UnitAffectingCombat("PLAYER") then
- showAfterCombat = true
- print("RT: "..itemLink.." was found but the player is in combat.")
- else
- FA_RTframe:Show()
- end
- end
- end
- local function onUpdate(self,elapsed)
- local currentTime = GetTime() -- get the time and put it in a variable so we don't have to call it a billion times throughout this function
- --[[ some other stuff --]]
- -- Item caching stuff
- if table_itemQuery[1] and currentTime >= table_itemQuery[1] then
- if debugOn then print("Checking for item info for "..(#table_itemQuery-1).." items...") end
- table_itemQuery[1] = currentTime+(cacheInterval/1000)
- local list_size = #table_itemQuery
- for i=0,list_size-2 do -- loop backwards through list of items waiting to be cached
- if GetItemInfo(table_itemQuery[list_size-i]) then -- check if this item in the list is cached yet
- if debugOn then print("Item info for "..table_itemQuery[list_size-i].." is ready, adding to loot window.") end
- FARaidTools:itemAdd(table_itemQuery[list_size-i]) -- it's ready so add it to the loot window
- table.remove(table_itemQuery, list_size-i) -- remove the entry from the query list
- --[[else
- if debugOn then print("Item info for "..table_itemQuery[list_size-i].." was not found.") end--]]
- end
- end
- if #table_itemQuery == 1 then
- table_itemQuery = {}
- elseif debugOn then
- print("Item info for "..(#table_itemQuery-1).." items is not ready. Checking again in "..cacheInterval.."ms.")
- end
- end
- end
- local ouframe = CreateFrame("frame")
- ouframe:SetScript("OnUpdate", onUpdate)
Advertisement
Add Comment
Please, Sign In to add comment