-
Posted by Gararf on Wed, 13 Aug 2008 18:07:05
Oki so im Scanning the guild bank, i want to use GetItemInfo because it contains info that i cant get anywhere else like item type, max stack etc. To use GetItemInfo the item has to be in my local cache, for it to be in my local cache then i have to have seen it on a tooltip.
i understand theres likely to be race issues when querying the server, but i have it on a delay between when the tooltip is set and when GetItemInfo is called, i know the tooltip works because i can see my tooltip being hyjacked, but GetItemInfo is still returning nils even after a 10s delay ........
i have tried various variations on how i set my tooltip, it shouldnt matter that im using the GameTooltip should it?
i've noticed that if items are really stored in the local cache if you see them then all the items in the guild bank i mouseover should work and return somthing useful, but they dont, so am i barking up the wrong tree? it does work however if i put items from the guild bank into my inventory and put em back, but obviously i shouldnt have to do that and its not very practical for scanning the entire guild bank (and would make alot of spamm on the log)
it wold be extremely helpful if someone who has done somthing similar can paste me some code so i can compare, i've checked atlasloot, but the server queries there arent needed for the local cache.
im loathe to put my own code up here because its abit messy with all this trial and error, and im not very experienced, you'll just have to trust me that it works the way its meant to except for this 1 thing ...
PASTE INCOMING!
function GBMFunctions.ScanSequencer(NumTabs)
if NumTabs > 0 then
local mydate = tostring(date("%d/%m/%Y"))
local hour, minute = GetGameTime()
local Hour = tostring(hour)
local Minute = tostring(minute)
GBMCharacterData.LastScan = mydate .. "/" .. Hour .. "/" .. Minute
GBMFunctions.ResetItemQuantities()
GBMVariables.TypesOfItems = 0
GBMVariables.TotalItems = 0
GBMVariables.ScanningBoolean = true
local flashtime = NumTabs+1
UIFrameFlash(getglobal("ScanningInProgressFrame"), 0.3, 0.3, flashtime, false, 0, 0)
--GBMFunctions.ScanRepeater(0)
SetCurrentGuildBankTab(1)
QueryGuildBankTab(1)
end
end
function GBMFunctions.ScanRepeater(tab)
if tab < GBMVariables.NumTabs then
tab = tab+1
SetCurrentGuildBankTab(tab)
QueryGuildBankTab(tab)
end
end
function GBMFunctions.ScanGuildBankSlot() -- function is run for each slot that contains an item, it is kept seperate because of a delay for item information to become available through tooltip
local slot = GBMVariables.SlotToScan
local tab = GetCurrentGuildBankTab()
local NumItemSlotsPerTab = 98
GBMFunctions.out("Slot Scan Called on slot: " .. slot)
if GBMVariables.ScanningBoolean == true then
if GBMCharacterData["Tab" .. tab .."Viewable"] == 1 then -- Only try scanning the tab if we can see it
local texture , count , locked = GetGuildBankItemInfo(tab , slot)
local ItemLink = GetGuildBankItemLink(tab , slot)
GBMFunctions.out(tostring(ItemLink))
if (ItemLink) then
local ItemName = GBMFunctions.ParseLink(ItemLink)
local name, link, quality, iLevel, reqLevel, iType, subType, maxStack, equipSlot, texture = GetItemInfo(ItemName)
GBMFunctions.out(ItemName .. " Item Type:")
GBMFunctions.out(tostring(iType))
if (quality) then
else
quality = 1
end
GBMFunctions.AddItem("Scan" , ItemName , count, texture , quality , tab , slot)
end
else
GBMFunctions.out("Tab ".. tab .. " Skipped because you cannot view this tab")
GBMFunctions.TimerEnd(timerNo)
GBMFunctions.ScanRepeater(tab)
end
end
if slot >= NumItemSlotsPerTab then
if GBMVariables.NumTabs > tab then
else
GBMVariables.ScanningBoolean = false
GBMFunctions.OutputItemSummary()
end
GBMFunctions.ScanRepeater(tab)
else
local nextSlot = slot + 1
GBMFunctions.PreliminaryScanSlot(nextSlot)
end
end
function GBMFunctions.PreliminaryScanSlot(slot)
if not (slot) then
slot = 1
end
local tab = GetCurrentGuildBankTab()
local NumItemSlotsPerTab = 98
if (slot <= NumItemSlotsPerTab) then
if GBMCharacterData["Tab" .. tab .."Viewable"] == 1 then -- Only try scanning the tab if we can see it
repeat
local texture , count , locked = GetGuildBankItemInfo(tab , slot)
local ItemLink = GetGuildBankItemLink(tab , slot)
local ItemInSlotBoolean = false
local EndLoopBoolean = false
if (count > 0) then --if there is an item in this slot then set the tooltip and wait for the data to be available before fully scanning
ItemInSlotBoolean = true
-- This expression extracts the item ID from the link
local justItemId = string.gsub(ItemLink,".-\124H([^\124]*)\124h.*", "%1");
GBMFunctions.out(justItemId)
GameTooltip:SetHyperlink(justItemId)
GBMVariables.SlotToScan = slot
GBMFunctions.NewTimer("SlotScanDelay" , 10 , "ScanGuildBankSlot" , 10)
ItemInSlotBoolean = false -- reset the if conditions because it appears every slot is stil scanned when it shouldnt be
EndLoopBoolean = true
count = nil
else
slot = slot + 1
end
until ((slot == 98) or (EndLoopBoolean == true))
end
else
if GBMVariables.NumTabs > tab then
else
GBMVariables.ScanningBoolean = false
GBMFunctions.OutputItemSummary()
end
GBMFunctions.ScanRepeater(tab)
end
-- Need to check if we have reached the end again because the slot number may have been pushed up because there is no item there
if (slot == NumItemSlotsPerTab) then
if GBMVariables.NumTabs > tab then
GBMFunctions.ScanRepeater(tab)
else
GBMVariables.ScanningBoolean = false
GBMFunctions.OutputItemSummary()
end
end
end -
Posted by Gararf on Wed, 13 Aug 2008 18:07:06
Oki so im Scanning the guild bank, i want to use GetItemInfo because it contains info that i cant get anywhere else like item type, max stack etc. To use GetItemInfo the item has to be in my local cache, for it to be in my local cache then i have to have seen it on a tooltip.
i understand theres likely to be race issues when querying the server, but i have it on a delay between when the tooltip is set and when GetItemInfo is called, i know the tooltip works because i can see my tooltip being hyjacked, but GetItemInfo is still returning nils even after a 10s delay ........
i have tried various variations on how i set my tooltip, it shouldnt matter that im using the GameTooltip should it?
i've noticed that if items are really stored in the local cache if you see them then all the items in the guild bank i mouseover should work and return somthing useful, but they dont, so am i barking up the wrong tree? it does work however if i put items from the guild bank into my inventory and put em back, but obviously i shouldnt have to do that and its not very practical for scanning the entire guild bank (and would make alot of spamm on the log)
it wold be extremely helpful if someone who has done somthing similar can paste me some code so i can compare, i've checked atlasloot, but the server queries there arent needed for the local cache.
im loathe to put my own code up here because its abit messy with all this trial and error, and im not very experienced, you'll just have to trust me that it works the way its meant to except for this 1 thing ...
PASTE INCOMING!
function GBMFunctions.ScanSequencer(NumTabs)
if NumTabs > 0 then
local mydate = tostring(date("%d/%m/%Y"))
local hour, minute = GetGameTime()
local Hour = tostring(hour)
local Minute = tostring(minute)
GBMCharacterData.LastScan = mydate .. "/" .. Hour .. "/" .. Minute
GBMFunctions.ResetItemQuantities()
GBMVariables.TypesOfItems = 0
GBMVariables.TotalItems = 0
GBMVariables.ScanningBoolean = true
local flashtime = NumTabs+1
UIFrameFlash(getglobal("ScanningInProgressFrame"), 0.3, 0.3, flashtime, false, 0, 0)
--GBMFunctions.ScanRepeater(0)
SetCurrentGuildBankTab(1)
QueryGuildBankTab(1)
end
end
function GBMFunctions.ScanRepeater(tab)
if tab < GBMVariables.NumTabs then
tab = tab+1
SetCurrentGuildBankTab(tab)
QueryGuildBankTab(tab)
end
end
function GBMFunctions.ScanGuildBankSlot() -- function is run for each slot that contains an item, it is kept seperate because of a delay for item information to become available through tooltip
local slot = GBMVariables.SlotToScan
local tab = GetCurrentGuildBankTab()
local NumItemSlotsPerTab = 98
GBMFunctions.out("Slot Scan Called on slot: " .. slot)
if GBMVariables.ScanningBoolean == true then
if GBMCharacterData["Tab" .. tab .."Viewable"] == 1 then -- Only try scanning the tab if we can see it
local texture , count , locked = GetGuildBankItemInfo(tab , slot)
local ItemLink = GetGuildBankItemLink(tab , slot)
GBMFunctions.out(tostring(ItemLink))
if (ItemLink) then
local ItemName = GBMFunctions.ParseLink(ItemLink)
local name, link, quality, iLevel, reqLevel, iType, subType, maxStack, equipSlot, texture = GetItemInfo(ItemName)
GBMFunctions.out(ItemName .. " Item Type:")
GBMFunctions.out(tostring(iType))
if (quality) then
else
quality = 1
end
GBMFunctions.AddItem("Scan" , ItemName , count, texture , quality , tab , slot)
end
else
GBMFunctions.out("Tab ".. tab .. " Skipped because you cannot view this tab")
GBMFunctions.TimerEnd(timerNo)
GBMFunctions.ScanRepeater(tab)
end
end
if slot >= NumItemSlotsPerTab then
if GBMVariables.NumTabs > tab then
else
GBMVariables.ScanningBoolean = false
GBMFunctions.OutputItemSummary()
end
GBMFunctions.ScanRepeater(tab)
else
local nextSlot = slot + 1
GBMFunctions.PreliminaryScanSlot(nextSlot)
end
end
function GBMFunctions.PreliminaryScanSlot(slot)
if not (slot) then
slot = 1
end
local tab = GetCurrentGuildBankTab()
local NumItemSlotsPerTab = 98
if (slot <= NumItemSlotsPerTab) then
if GBMCharacterData["Tab" .. tab .."Viewable"] == 1 then -- Only try scanning the tab if we can see it
repeat
local texture , count , locked = GetGuildBankItemInfo(tab , slot)
local ItemLink = GetGuildBankItemLink(tab , slot)
local ItemInSlotBoolean = false
local EndLoopBoolean = false
if (count > 0) then --if there is an item in this slot then set the tooltip and wait for the data to be available before fully scanning
ItemInSlotBoolean = true
-- This expression extracts the item ID from the link
local justItemId = string.gsub(ItemLink,".-\124H([^\124]*)\124h.*", "%1");
GBMFunctions.out(justItemId)
GameTooltip:SetHyperlink(justItemId)
GBMVariables.SlotToScan = slot
GBMFunctions.NewTimer("SlotScanDelay" , 10 , "ScanGuildBankSlot" , 10)
ItemInSlotBoolean = false -- reset the if conditions because it appears every slot is stil scanned when it shouldnt be
EndLoopBoolean = true
count = nil
else
slot = slot + 1
end
until ((slot == 98) or (EndLoopBoolean == true))
end
else
if GBMVariables.NumTabs > tab then
else
GBMVariables.ScanningBoolean = false
GBMFunctions.OutputItemSummary()
end
GBMFunctions.ScanRepeater(tab)
end
-- Need to check if we have reached the end again because the slot number may have been pushed up because there is no item there
if (slot == NumItemSlotsPerTab) then
if GBMVariables.NumTabs > tab then
GBMFunctions.ScanRepeater(tab)
else
GBMVariables.ScanningBoolean = false
GBMFunctions.OutputItemSummary()
end
end
end -
Posted by jnwhiteh on Thu, 14 Aug 2008 02:50:58
I'm going to try to look at this later, but what you're trying to do is an extremely special purpose thing. Also, would you mind formatting your code as "Preformatted" next time when you post, or paste it on pastey.net? It makes the code a ton easier to read when its properly formatted and colored.
-
Posted by Gararf on Thu, 14 Aug 2008 07:08:45
http://pastey.net/93795
there you go.
to b honest i doubt you will be able to scry anything new from the code, i think its more my lack of understanding how the local item cache works.
the more i think about it the closer i am coming to the conclusion that you cannot get items into your local cache without having them in your inventory
-
Posted by Gararf on Thu, 14 Aug 2008 07:13:52
are there any libraries that contain item data ?
i cant scan tooltips, with things like trade goods e.g. void crystal the only thing you get is the name
-
Posted by jnwhiteh on Wed, 20 Aug 2008 09:29:48
There are libraries that contain item info, but that information is limited[1]. Loading the tooltip also shouldn't be necessary (from my understanding) in order to get returns from
GetItemInfo()
. You are saying that you can open your guild bank, get an itemid/number/link and then feed that intoGetItemInfo()
and receive no results? Completely forget the code that you have to automatically scan things, since it's just confusing the matter. Do you have any issues when querying this information manually?