move a pile of shit around, add equipping record support
[QuestHelper.git] / collect_item.lua
blob032e65a17bcbde2785e59614270000cdd66adfa5
1 QuestHelper_File["collect_item.lua"] = "Development Version"
3 local debug_output = false
4 if QuestHelper_File["collect_item.lua"] == "Development Version" then debug_output = true end
6 local GetItemType
8 local QHCI
10 -- We could probably snag data from other locations as well, but at the moment, we're not.
11 local function Tooltipy(self, ...)
12 local _, ilink = self:GetItem()
13 if not ilink then return end
15 local id = GetItemType(ilink)
17 if not QHCI[id] then QHCI[id] = {} end
18 local item = QHCI[id]
20 local name, _, quality, ilvl, min, itype, isubtype, _, equiploc, _ = GetItemInfo(id)
22 if name then
23 item.name = name
24 item.quality = quality
25 item.ilevel = ilvl
26 item.minlevel = min
27 item.type = string.format("%s/%s", itype, isubtype)
29 local loc = string.match(equiploc, "INVTYPE_(.*)")
30 if loc then
31 item.equiplocation = loc
32 else
33 item.equiplocation = nil
34 end
36 local lines = GameTooltip:NumLines()
37 local openable = false
38 for i = 2, lines do
39 if _G["GameTooltipTextLeft" .. tostring(i)]:GetText() == ITEM_OPENABLE then
40 openable = true
41 end
42 end
44 openable = "open_" .. (openable and "yes" or "no")
45 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.
46 end
47 end
49 function QH_Collect_Item_Init(QHCData, API)
50 if not QHCData.item then QHCData.item = {} end
51 QHCI = QHCData.item
53 API.Registrar_TooltipHook(Tooltipy)
55 GetItemType = API.Utility_GetItemType
56 QuestHelper: Assert(GetItemType)
57 end