From 816245588d62e3364b974be07989298887c45cfe Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 11 Dec 2019 12:25:08 +0100 Subject: Disable ARS train flag and surrounding uses --- advtrains_interlocking/approach.lua | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'advtrains_interlocking') 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 -- cgit v1.2.3