tweak the nag system slightly
[QuestHelper.git] / collect_notifier.lua
blob088af9e6a2a2edcbd756320665aef5db048bc213
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 table.insert(NotificationsPending, {time = time, func = func})
15 table.sort(NotificationsPending, function (a, b) return a.time < b.time end) -- haha who cares about efficiency anyway, NOT ME that is for certain
16 end
18 function QH_Collect_Notifier_Init(_, API)
19 API.Utility_Notifier = AddItem
21 API.Registrar_OnUpdateHook(OnUpdate)
22 end