aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation/scheduler.lua
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains_line_automation/scheduler.lua')
-rw-r--r--advtrains_line_automation/scheduler.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/advtrains_line_automation/scheduler.lua b/advtrains_line_automation/scheduler.lua
index b641597..3d8778a 100644
--- a/advtrains_line_automation/scheduler.lua
+++ b/advtrains_line_automation/scheduler.lua
@@ -116,4 +116,15 @@ function sched.enqueue_in(rwtime, handler, evtdata, unitid, unitlim)
sched.enqueue(ctime + rwtime, handler, evtdata, unitid, unitlim)
end
+-- Discards all schedules for unit "unitid" (removes them from the queue)
+function sched.discard_all(unitid)
+ for i=1,#queue do
+ if queue[i].u == unitid then
+ table.remove(queue,i)
+ i=i-1
+ end
+ end
+ units_cnt[unitid] = 0
+end
+
ln.sched = sched