let's give a little more info in the changelog
[QuestHelper.git] / collect_notifier.lua
blob071f55f53879b2d7911c199656ecb3af1e5ae8b5
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