disable the flight stuff for now, we'll fix it after thanksgiving
[QuestHelper.git] / collect_zone.lua
blob2adc0235281a86fad7e944c50a9e9320cf5390c8
1 QuestHelper_File["collect_zone.lua"] = "Development Version"
3 local debug_output = false
4 if QuestHelper_File["collect_traveled.lua"] == "Development Version" then debug_output = true end
6 local QHCZ
8 local GetLoc
9 local Merger
11 local function DoZoneUpdate(label, debugverbose)
12 local zname = string.format("%s@@%s@@%s", GetZoneText(), GetRealZoneText(), GetSubZoneText()) -- I don't *think* any zones will have a @@ in them :D
13 if zname == "@@@@" then return end -- denied
14 if not QHCZ[zname] then QHCZ[zname] = {} end
15 if not QHCZ[zname][label] then QHCZ[zname][label] = {} end
16 local znl = QHCZ[zname][label]
18 if debugverbose and debug_output then
19 --QuestHelper:TextOut("zoneupdate " .. zname .. " type " .. label)
20 end
22 QHCZ[zname].mapname = GetMapInfo()
23 local loc = GetLoc()
24 if #znl > 0 and string.sub(znl[#znl], -#loc) == loc then return end -- stop repeating things, a purse is not food
25 Merger.Add(znl, loc)
26 end
28 local function OnEvent()
29 DoZoneUpdate("border", true)
30 end
32 local lastupdate = 0
33 local function OnUpdate()
34 if lastupdate + 15 <= GetTime() then
35 DoZoneUpdate("update")
36 lastupdate = GetTime()
37 end
38 end
40 function QH_Collect_Zone_Init(QHCData, API)
41 if not QHCData.zone then QHCData.zone = {} end
42 QHCZ = QHCData.zone
44 API.Registrar_EventHook("ZONE_CHANGED", OnEvent)
45 API.Registrar_EventHook("ZONE_CHANGED_INDOORS", OnEvent)
46 API.Registrar_EventHook("ZONE_CHANGED_NEW_AREA", OnEvent)
48 API.Registrar_OnUpdateHook(OnUpdate)
50 GetLoc = API.Callback_LocationBolusCurrent
51 QuestHelper: Assert(GetLoc)
53 Merger = API.Utility_Merger
54 QuestHelper: Assert(Merger)
55 end