diff options
author | orwell96 <orwell@bleipb.de> | 2019-11-06 22:07:10 +0100 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2019-11-06 22:07:10 +0100 |
commit | 8c55442076c9d5cfed89bac3f4acd22ea7948dd3 (patch) | |
tree | 170bd44fdd0c015b9995e0cdb483e5f270433af4 /advtrains_line_automation | |
parent | 43b4d863ec379f5b2639194b929a45fd3a18be78 (diff) | |
download | advtrains-8c55442076c9d5cfed89bac3f4acd22ea7948dd3.tar.gz advtrains-8c55442076c9d5cfed89bac3f4acd22ea7948dd3.tar.bz2 advtrains-8c55442076c9d5cfed89bac3f4acd22ea7948dd3.zip |
Add "discard all" function to scheduler events and use it to clear schedules in luaatc rails
Diffstat (limited to 'advtrains_line_automation')
-rw-r--r-- | advtrains_line_automation/scheduler.lua | 11 |
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 |