Automated update from: http://smariot.no-ip.org/translate
[QuestHelper.git] / collect_notifier.lua
blob931d3d92acf493005fcc2235936405de58c48d0d
1 QuestHelper_File["collect_notifier.lua"] = "Development Version"
2 QuestHelper_Loadtime["collect_notifier.lua"] = GetTime()
4 local NotificationsPending = {}
6 local function OnUpdate()
7 while #NotificationsPending > 0 and GetTime() >= NotificationsPending[1].time do
8 NotificationsPending[1].func()
9 table.remove(NotificationsPending, 1) -- okay okay n^2 deal with it
10 end
11 end
13 local function AddItem(time, func)
14 QuestHelper: Assert(time)
15 QuestHelper: Assert(func)
16 table.insert(NotificationsPending, {time = time, func = func})
17 table.sort(NotificationsPending, function (a, b) return a.time < b.time end) -- haha who cares about efficiency anyway, NOT ME that is for certain
18 end
20 function QH_Collect_Notifier_Init(_, API)
21 API.Utility_Notifier = AddItem
23 API.Registrar_OnUpdateHook(OnUpdate)
24 end
26 -- grrrr
27 QH_AddNotifier = AddItem