make right-click on minimap work better
[QuestHelper.git] / collect_zone.lua
blob76aaebadf352ee1d7ad0e534efc96004cadb7be5
1 QuestHelper_File["collect_zone.lua"] = "Development Version"
2 QuestHelper_Loadtime["collect_zone.lua"] = GetTime()
4 local debug_output = false
5 if QuestHelper_File["collect_zone.lua"] == "Development Version" then debug_output = true end
7 local QHCZ
9 local GetLoc
10 local Merger
12 local function DoZoneUpdate(label, debugverbose)
13 local zname = string.format("%s@@%s@@%s", GetZoneText(), GetRealZoneText(), GetSubZoneText()) -- I don't *think* any zones will have a @@ in them :D
14 if zname == "@@@@" then return end -- denied
15 if not QHCZ[zname] then QHCZ[zname] = {} end
16 if not QHCZ[zname][label] then QHCZ[zname][label] = {} end
17 local znl = QHCZ[zname][label]
19 if debugverbose and debug_output then
20 --QuestHelper:TextOut("zoneupdate " .. zname .. " type " .. label)
21 end
23 QHCZ[zname].mapname = GetMapInfo()
25 local loc = GetLoc()
26 if loc == "€\000\000\000\000\000\000€€€" then return end -- this is kind of the "null value"
28 Merger.Add(znl, loc, true)
29 end
31 local function OnEvent()
32 DoZoneUpdate("border", true)
33 end
35 local lastupdate = 0
36 local function OnUpdate()
37 if lastupdate + 15 <= GetTime() then
38 DoZoneUpdate("update")
39 lastupdate = GetTime()
40 end
41 end
43 function QH_Collect_Zone_Init(QHCData, API)
44 if not QHCData.zone then QHCData.zone = {} end
45 QHCZ = QHCData.zone
47 QH_Event("ZONE_CHANGED", OnEvent)
48 QH_Event("ZONE_CHANGED_INDOORS", OnEvent)
49 QH_Event("ZONE_CHANGED_NEW_AREA", OnEvent)
51 API.Registrar_OnUpdateHook(OnUpdate)
53 GetLoc = API.Callback_LocationBolusCurrent
54 QuestHelper: Assert(GetLoc)
56 Merger = API.Utility_Merger
57 QuestHelper: Assert(Merger)
58 end