aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-12-11 12:25:08 +0100
committerorwell96 <orwell@bleipb.de>2021-02-10 16:35:45 +0100
commit816245588d62e3364b974be07989298887c45cfe (patch)
treeb4166f07a0396b43d6af7bd41d1295101117d947 /advtrains_interlocking
parent74a219937dd031743c880510f10571adec0cf8a8 (diff)
downloadadvtrains-816245588d62e3364b974be07989298887c45cfe.tar.gz
advtrains-816245588d62e3364b974be07989298887c45cfe.tar.bz2
advtrains-816245588d62e3364b974be07989298887c45cfe.zip
Disable ARS train flag and surrounding uses
Diffstat (limited to 'advtrains_interlocking')
-rw-r--r--advtrains_interlocking/approach.lua19
1 files changed, 18 insertions, 1 deletions
diff --git a/advtrains_interlocking/approach.lua b/advtrains_interlocking/approach.lua
index 8e90b5a..7bb9fc9 100644
--- a/advtrains_interlocking/approach.lua
+++ b/advtrains_interlocking/approach.lua
@@ -50,7 +50,13 @@ advtrains.tnc_register_on_approach(function(pos, id, train, index, lzbdata)
local asp, spos = il.db.get_ip_signal_asp(pts, cn)
-- do ARS if needed
- if spos then
+ local ars_enabled = not train.ars_disable
+ -- Note on ars_disable:
+ -- Theoretically, the ars_disable flag would need to behave like the speed restriction field: it should be
+ -- stored in lzbdata and updated once the train drives over. However, for the sake of simplicity, it is simply
+ -- a value in the train. In this case, this is sufficient because once a train triggers ARS for the first time,
+ -- resetting the path does not matter to the set route and ARS doesn't need to be called again.
+ if spos and ars_enabled then
--atdebug(id,"IL Spos (ARS)",spos,asp)
local sigd = il.db.get_sigd_for_signal(spos)
if sigd then
@@ -111,3 +117,14 @@ advtrains.tnc_register_on_approach(function(pos, id, train, index, lzbdata)
lzbdata.travspd = travspd
lzbdata.travwspd = travwspd
end)
+
+-- Set the ars_disable flag to the value passed
+-- Triggers a path invalidation if set to false
+function advtrains.interlocking.ars_set_disable(train, value)
+ if value then
+ train.ars_disable = true
+ else
+ train.ars_disable = nil
+ minetest.after(0, advtrains.path_invalidate, train)
+ end
+end