Merge branch 'master' of zorba@192.168.100.11:questhelper
[QuestHelper.git] / collect_zone.lua
blobf076720ab312f1bca9e78ad222ff6c09d702f1b1
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_traveled.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()
24 Merger.Add(znl, GetLoc(), true)
25 end
27 local function OnEvent()
28 DoZoneUpdate("border", true)
29 end
31 local lastupdate = 0
32 local function OnUpdate()
33 if lastupdate + 15 <= GetTime() then
34 DoZoneUpdate("update")
35 lastupdate = GetTime()
36 end
37 end
39 function QH_Collect_Zone_Init(QHCData, API)
40 if not QHCData.zone then QHCData.zone = {} end
41 QHCZ = QHCData.zone
43 API.Registrar_EventHook("ZONE_CHANGED", OnEvent)
44 API.Registrar_EventHook("ZONE_CHANGED_INDOORS", OnEvent)
45 API.Registrar_EventHook("ZONE_CHANGED_NEW_AREA", OnEvent)
47 API.Registrar_OnUpdateHook(OnUpdate)
49 GetLoc = API.Callback_LocationBolusCurrent
50 QuestHelper: Assert(GetLoc)
52 Merger = API.Utility_Merger
53 QuestHelper: Assert(Merger)
54 end