update todo
[QuestHelper.git] / collect_item.lua
blob806e9f0416f3a6ee1c7bc3e0a7dd4a69fc3e20b0
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 if not self.GetItem then return end -- ughhhh, inventoryonpar
15 local _, ilink = self:GetItem()
16 if not ilink then return end
18 local id = GetItemType(ilink)
20 if not QHCI[id] then QHCI[id] = {} end
21 local item = QHCI[id]
23 local name, _, quality, ilvl, min, itype, isubtype, _, equiploc, _ = GetItemInfo(id)
25 if name then
26 item.name = name
27 item.quality = quality
28 item.ilevel = ilvl
29 item.minlevel = min
30 item.type = string.format("%s/%s", itype, isubtype)
32 local loc = string.match(equiploc, "INVTYPE_(.*)")
33 if loc then
34 item.equiplocation = loc
35 else
36 item.equiplocation = nil
37 end
39 local lines = GameTooltip:NumLines()
40 local openable = false
41 for i = 2, lines do
42 if _G["GameTooltipTextLeft" .. tostring(i)]:GetText() == ITEM_OPENABLE then
43 openable = true
44 end
45 end
47 openable = "open_" .. (openable and "yes" or "no")
48 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.
49 end
50 end
52 function QH_Collect_Item_Init(QHCData, API)
53 if not QHCData.item then QHCData.item = {} end
54 QHCI = QHCData.item
56 API.Registrar_TooltipHook(Tooltipy)
58 GetItemType = API.Utility_GetItemType
59 QuestHelper: Assert(GetItemType)
60 end