aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-10-26 20:23:19 +0200
committerorwell96 <orwell@bleipb.de>2021-10-26 20:23:19 +0200
commit75025b13ca3b90c0ed284920ab0f294c54eeb697 (patch)
tree5f19ce613c5f36d8e22b7a2c986b544c2ddceecd
parent4e80866ca6156a9fa65e8c8539c0756ee5ae7a50 (diff)
downloadadvtrains-master.tar.gz
advtrains-master.tar.bz2
advtrains-master.zip
Route Formspec: When cancelling route, disable ARS only temporarily, not permanentlyHEADmaster
-rw-r--r--advtrains_interlocking/ars.lua4
-rwxr-xr-xadvtrains_interlocking/tcb_ts_ui.lua13
2 files changed, 13 insertions, 4 deletions
diff --git a/advtrains_interlocking/ars.lua b/advtrains_interlocking/ars.lua
index 434ae2c..4f50df9 100644
--- a/advtrains_interlocking/ars.lua
+++ b/advtrains_interlocking/ars.lua
@@ -133,9 +133,11 @@ function advtrains.interlocking.ars_check(sigd, train)
local tcbs = il.db.get_tcbs(sigd)
if not tcbs or not tcbs.routes then return end
- if tcbs.ars_disabled then
+ if tcbs.ars_disabled or tcbs.ars_ignore_next then
-- No-ARS mode of signal.
-- ignore...
+ -- Note: ars_ignore_next is set by signalling formspec when route is cancelled
+ tcbs.ars_ignore_next = nil
return
end
diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua
index 34fbf7f..0cc10da 100755
--- a/advtrains_interlocking/tcb_ts_ui.lua
+++ b/advtrains_interlocking/tcb_ts_ui.lua
@@ -723,11 +723,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
connid = tonumber(connids)
if not connid or connid<1 or connid>2 then return end
end
- if pos and connid and not fields.quit then
+ if pos and connid then
local sigd = {p=pos, s=connid}
local tcbs = ildb.get_tcbs(sigd)
if not tcbs then return end
-
+
+ if fields.quit then
+ -- form quit: disable temporary ARS ignore
+ tcbs.ars_ignore_next = nil
+ return
+ end
+
local sel_rte
if fields.rtelist then
local tev = minetest.explode_textlist_event(fields.rtelist)
@@ -740,7 +746,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
if tcbs.routeset and fields.cancelroute then
if tcbs.routes[tcbs.routeset] and tcbs.routes[tcbs.routeset].ars then
- tcbs.ars_disabled = true
+ tcbs.ars_ignore_next = true
end
-- if route committed, cancel route ts info
ilrs.update_route(sigd, tcbs, nil, true)
@@ -749,6 +755,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields.newroute and hasprivs then
advtrains.interlocking.init_route_prog(pname, sigd)
minetest.close_formspec(pname, formname)
+ tcbs.ars_ignore_next = nil
return
end
if sel_rte and tcbs.routes[sel_rte] then