fingers crossed
[QuestHelper.git] / collect_item.lua
blobc2cf8db5b4da9f2f95ce182c989a779b2c363344
1 QuestHelper_File["collect_item.lua"] = "Development Version"
2 QuestHelper_Loadtime["collect_item.lua"] = GetTime()
4 local debug_output = false
5 if QuestHelper_File["collect_item.lua"] == "Development Version" then debug_output = true end
7 local GetItemType
9 local QHCI
11 -- We could probably snag data from other locations as well, but at the moment, we're not.
12 local function Tooltipy(self, ...)
13 local _, ilink = self:GetItem()
14 if not ilink then return end
16 local id = GetItemType(ilink)
18 if not QHCI[id] then QHCI[id] = {} end
19 local item = QHCI[id]
21 local name, _, quality, ilvl, min, itype, isubtype, _, equiploc, _ = GetItemInfo(id)
23 if name then
24 item.name = name
25 item.quality = quality
26 item.ilevel = ilvl
27 item.minlevel = min
28 item.type = string.format("%s/%s", itype, isubtype)
30 local loc = string.match(equiploc, "INVTYPE_(.*)")
31 if loc then
32 item.equiplocation = loc
33 else
34 item.equiplocation = nil
35 end
37 local lines = GameTooltip:NumLines()
38 local openable = false
39 for i = 2, lines do
40 if _G["GameTooltipTextLeft" .. tostring(i)]:GetText() == ITEM_OPENABLE then
41 openable = true
42 end
43 end
45 openable = "open_" .. (openable and "yes" or "no")
46 item[openable] = (item[openable] or 0) + 1 -- so we're going to add a lot to this if the user keeps whipping their mouse over it. I'll live.
47 end
48 end
50 function QH_Collect_Item_Init(QHCData, API)
51 if not QHCData.item then QHCData.item = {} end
52 QHCI = QHCData.item
54 API.Registrar_TooltipHook(Tooltipy)
56 GetItemType = API.Utility_GetItemType
57 QuestHelper: Assert(GetItemType)
58 end