/trunk/zz_itemsdb
local modul = { |
['name'] = modulname |
} |
local playerID |
local function getCurrencyItem(index) |
local currencyLink = GetCurrencyListLink(index) |
if(currencyLink) then |
end |
function events:CURRENCY_DISPLAY_UPDATE(event) |
modul['db'][playerID] = modul['db'][playerID] or {} |
for index=1,GetCurrencyListSize() do |
local name, isHeader, isExpanded, isUnused, isWatched, count, icon, maximum, hasWeeklyLimit, currentWeeklyAmount =GetCurrencyListInfo(index) |
local itemID = getCurrencyItem(index) |
if((not isHeader) and itemID) then |
modul['db'][playerID][tonumber(itemID)] = { |
['count'] = count, |
['max'] = maximum, |
} |
addon['setIcon'](itemID, icon) |
local playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
for index=1,GetCurrencyListSize() do |
local name, isHeader, isExpanded, isUnused, isWatched, count, icon, maximum, hasWeeklyLimit, currentWeeklyAmount =GetCurrencyListInfo(index) |
local itemID = getCurrencyItem(index) |
if((not isHeader) and itemID) then |
modul['db'][playerID][tonumber(itemID)] = { |
['count'] = count, |
['max'] = maximum, |
} |
addon['setIcon'](itemID, icon) |
end |
end |
end |
end |
local function OnEvent(self,event,...) |
playerID = addon.getPID() |
local playerID = addon.getPID() |
if(playerID and type(events[event])=='function') then |
modul['db'] = addon:GetNamespace(modul.name) |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
end |
end |
local function checkID(itemID) |
--From idTip: http://www.wowinterface.com/downloads/info17033-idTip.html |
print(itemID,type(itemID)) |
if(TradeSkillFrame ~= nil and TradeSkillFrame:IsVisible()) then |
print("TradeSkillFrame") |
if (GetMouseFocus():GetName()) == "TradeSkillSkillIcon" then |
print("tsicon") |
itemId = GetTradeSkillItemLink(TradeSkillFrame.selectedSkill):match("item:(%d+):") or nil |
else |
print("hum") |
for i = 1, 8 do |
print(GetMouseFocus():GetName()) |
if (GetMouseFocus():GetName()) == "TradeSkillFrame.DetailsFrame.Contents.Reagent"..i then |
itemId = GetTradeSkillReagentItemLink(TradeSkillFrame.selectedSkill, i):match("item:(%d+):") or nil |
break |
end |
end |
end |
end |
return tonumber(itemID) |
end |
local function GameTooltip_OnTooltipSetItem(tooltip) |
local _, link = tooltip:GetItem() |
if(not link) then |
return |
end |
local id = addon['getItemId'](link) |
if(not id) then |
local spellId = strmatch(link, "enchant:(%d+)") |
local spell = GetSpellInfo(spellId) |
print(spellId,spell) |
id = checkID(id) |
end |
if(id)then |
tooltip:AddLine() |
for name,b in pairs(search(id)) do |
end |
end |
end |
local function GameTooltip_SetRecipeReagentItem(tooltip, recipe, reagentID) |
if(db['showID']) then |
tooltip:AddLine(format("Id: %i",id)) |
end |
end |
GameTooltip:HookScript("OnTooltipSetItem", GameTooltip_OnTooltipSetItem) |
--GameTooltip:HookScript("SetRecipeReagentItem", GameTooltip_SetRecipeReagentItem) |
addon['funcSync'] = function(func,delayed) |
local st = GetTime() |
if(delayed and sync[func]['times'][delayed]) then |
local modul = { |
['name'] = modulname |
} |
local playerID |
local BankIsOpen = false |
local function scanAllBankBags(delayed) |
if(not BankIsOpen) then return end |
for k,v in pairs(modul['db']) do |
local units = addon['getUnits']() |
if(units[k]) then |
if(units[k]['faction']==units[playerID]['faction']) then |
local playerID = addon.getPID() |
if(playerID and units[k]['faction']==units[playerID]['faction']) then |
local unitname = units[k]['name'] |
for bag,list in pairs(v) do |
if(bag == -3) then |
return res |
end |
function modul.Search(id,res) |
if(not playerID) then |
playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
local playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
return playerID and bagLoop(id,res) or res |
end |
scanAllBankBags(nil) |
end |
local function OnEvent(self,event,...) |
playerID = addon.getPID() |
local playerID = addon.getPID() |
if(playerID and type(events[event])=='function') then |
modul['db'] = addon:GetNamespace(modul.name) |
modul['db'][playerID] = modul['db'][playerID] or {} |
local modul = { |
['name'] = modulname |
} |
local playerID |
function addon.scanBag(bag) |
local slot = 1 |
local itemlist = {} |
end |
local function scanAllBags(delayed) |
if(not addon['funcSync'](scanAllBags,delayed)) then return end |
for bag=0,4 do |
modul['db'][playerID][bag] = addon['scanBag'](bag) -- loop all bought bags |
end |
for k,v in pairs(modul['db'][playerID]) do |
if(k<0 or k>4) then |
modul['db'][playerID][k] = nil -- prevent bogus bags |
local playerID = addon.getPID() |
if(playerID) then |
for bag=0,4 do |
modul['db'][playerID][bag] = addon['scanBag'](bag) -- loop all bought bags |
end |
for k,v in pairs(modul['db'][playerID]) do |
if(k<0 or k>4) then |
modul['db'][playerID][k] = nil -- prevent bogus bags |
end |
end |
end |
end |
local function bagLoop(id,res) |
for k,v in pairs(modul['db']) do |
local units = addon['getUnits']() |
if(units[k]) then |
if(units[k]['faction']==units[playerID]['faction']) then |
local playerID = addon.getPID() |
if(playerID and units[k]['faction']==units[playerID]['faction']) then |
local unitname = units[k]['name'] |
for bag,list in pairs(v) do |
for a,b in pairs(list) do |
return res |
end |
function modul.Search(id,res) |
if(not playerID) then |
playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
local playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
return playerID and bagLoop(id,res) or res |
end |
return input,sum |
end |
function events:BAG_UPDATE(event,bag) |
modul['db'][playerID][bag] = addon['scanBag'](bag) |
local playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID][bag] = addon['scanBag'](bag) |
end |
end |
function events:ITEM_UNLOCKED(event,...) |
scanAllBags(nil) |
scanAllBags(nil) |
end |
local function OnEvent(self,event,...) |
playerID = addon.getPID() |
local playerID = addon.getPID() |
if(playerID and type(events[event])=='function') then |
modul['db'] = addon:GetNamespace(modul.name) |
modul['db'][playerID] = modul['db'][playerID] or {} |
local modul = { |
['name'] = modulname |
} |
local playerID |
local function scanChar() |
local itemlist = {} |
local empty = true |
for k,v in pairs(modul['db']) do |
local units = addon['getUnits']() |
if(units[k]) then |
if(units[k]['faction']==units[playerID]['faction']) then |
local playerID = addon.getPID() |
if(playerID and units[k]['faction']==units[playerID]['faction']) then |
local unitname = units[k]['name'] |
for bag,list in pairs(v) do |
for a,b in pairs(list) do |
return res |
end |
function modul.Search(id,res) |
if(not playerID) then |
playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
local playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
return playerID and bagLoop(id,res) or res |
end |
return input,sum |
end |
function events:UNIT_INVENTORY_CHANGED(event,...) |
modul['db'][playerID][0] = scanChar(nil) |
local playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID][0] = scanChar(nil) |
end |
end |
function events:ITEM_UNLOCKED(event,...) |
modul['db'][playerID][0] = scanChar(nil) |
local playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID][0] = scanChar(nil) |
end |
end |
local function OnEvent(self,event,...) |
playerID = addon.getPID() |
local playerID = addon.getPID() |
if(playerID and type(events[event])=='function') then |
modul['db'] = addon:GetNamespace(modul.name) |
modul['db'][playerID] = modul['db'][playerID] or {} |
['name'] = modulname, |
['typ'] = 'guild' |
} |
local guildID |
local GuildBankIsOpen = false |
local function gbagLoop(id) |
local res = {} |
for k,v in pairs(modul['db']) do |
local guilds = addon['getGuilds']() |
if(guilds[k]) then |
local guildID = addon.getGID() |
if(guildID and guilds[k]['faction']==guilds[guildID]['faction'] or not guildID) then |
local guildname = guilds[k]['name'] |
for bag,list in pairs(v) do |
return res |
end |
function modul.Search2(id,res,mode) |
if(not guildID) then |
guildID = addon.getGID() |
if(guildID) then |
modul['db'][guildID] = modul['db'][guildID] or {} |
end |
local guildID = addon.getGID() |
if(guildID) then |
modul['db'][guildID] = modul['db'][guildID] or {} |
end |
res = res or {} |
for guildname, b in pairs(gbagLoop(id)) do |
if(not addon.checkGID() or not GuildBankIsOpen) then return end |
local tab = GetCurrentGuildBankTab() |
if(tab>0) then |
local list = scanGuildBank(tab) |
if(list and guildID) then |
modul['db'][guildID][tab] = list |
local guildID = addon.getGID() |
if(guildID) then |
local list = scanGuildBank(tab) |
if(list) then |
modul['db'][guildID][tab] = list |
end |
end |
end |
end |
GuildBankIsOpen = true |
end |
local function OnEvent(self,event,...) |
guildID = addon.getGID() |
local guildID = addon.getGID() |
if(guildID and type(events[event])=='function') then |
modul['db'] = addon:GetNamespace(modul.name) |
modul['db'][guildID] = modul['db'][guildID] or {} |
local modul = { |
['name'] = modulname |
} |
local playerID |
local voidOpen |
local function scanVoid() |
if(not voidOpen) then return end |
local itemlist = {} |
local empty = true |
for tab=1,2 do |
for slot=1,80 do |
local id, icon = GetVoidItemInfo(tab, slot) |
if(id) then |
id = tonumber(id) |
empty = false |
itemlist[id] = itemlist[id] or {} |
itemlist[id]['count'] = (itemlist[id]['count'] or 0) + 1 |
addon['getName'](id) |
addon['setIcon'](id, icon) |
local playerID = addon.getPID() |
if(playerID) then |
local itemlist = {} |
local empty = true |
for tab=1,2 do |
for slot=1,80 do |
local id, icon = GetVoidItemInfo(tab, slot) |
if(id) then |
id = tonumber(id) |
empty = false |
itemlist[id] = itemlist[id] or {} |
itemlist[id]['count'] = (itemlist[id]['count'] or 0) + 1 |
addon['getName'](id) |
addon['setIcon'](id, icon) |
end |
end |
end |
modul['db'][playerID][0] = itemlist |
end |
return empty and nil or itemlist |
end |
local function bagLoop(id,res) |
local dName = modulname.."Count" |
for k,v in pairs(modul['db']) do |
local units = addon['getUnits']() |
if(units[k]) then |
if(units[k]['faction']==units[playerID]['faction']) then |
local playerID = addon.getPID() |
if(playerID and units[k]['faction']==units[playerID]['faction']) then |
local unitname = units[k]['name'] |
for bag,list in pairs(v) do |
for a,b in pairs(list) do |
return res |
end |
function modul.Search(id,res) |
if(not playerID) then |
playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
local playerID = addon.getPID() |
if(playerID) then |
modul['db'][playerID] = modul['db'][playerID] or {} |
end |
return playerID and bagLoop(id,res) or res |
end |
end |
function events:VOID_STORAGE_OPEN(event,...) |
voidOpen = true |
modul['db'][playerID][0] = scanVoid() |
scanVoid() |
end |
function events:VOID_STORAGE_CONTENTS_UPDATE(event,...) |
modul['db'][playerID][0] = scanVoid() |
scanVoid() |
end |
function events:VOID_STORAGE_DEPOSIT_UPDATE(event,...) |
modul['db'][playerID][0] = scanVoid() |
scanVoid() |
end |
function events:ITEM_UNLOCKED(event,...) |
modul['db'][playerID][0] = scanVoid() |
scanVoid() |
end |
function events:VOID_TRANSFER_DONE(event,...) |
modul['db'][playerID][0] = scanVoid() |
scanVoid() |
end |
local function OnEvent(self,event,...) |
playerID = addon.getPID() |
local playerID = addon.getPID() |
if(playerID and type(events[event])=='function') then |
modul['db'] = addon:GetNamespace(modul.name) |
modul['db'][playerID] = modul['db'][playerID] or {} |