From 5738ab46aa5c768b973ef892635fb1642c5f6b9c Mon Sep 17 00:00:00 2001 From: orwell96 Date: Fri, 15 Mar 2019 18:17:18 +0100 Subject: Disable-ARS switch in signal and set this when cancelling an ARS route --- advtrains_interlocking/ars.lua | 11 ++++++++--- advtrains_interlocking/tcb_ts_ui.lua | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'advtrains_interlocking') diff --git a/advtrains_interlocking/ars.lua b/advtrains_interlocking/ars.lua index ef5d0da..5bb56fa 100644 --- a/advtrains_interlocking/ars.lua +++ b/advtrains_interlocking/ars.lua @@ -114,8 +114,16 @@ 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 + -- No-ARS mode of signal. + -- ignore... + return + end + if tcbs.routeset then -- ARS is not in effect when a route is already set + -- just "punch" routesetting, just in case callback got lost. + minetest.after(0, il.route.update_route, sigd, tcbs, nil, nil) return end @@ -124,8 +132,5 @@ function advtrains.interlocking.ars_check(sigd, train) --delay routesetting, it should not occur inside train step -- using after here is OK because that gets called on every path recalculation minetest.after(0, il.route.update_route, sigd, tcbs, rteid, nil) - else - -- just "punch" routesetting, just in case callback got lost. - minetest.after(0, il.route.update_route, sigd, tcbs, nil, nil) end end diff --git a/advtrains_interlocking/tcb_ts_ui.lua b/advtrains_interlocking/tcb_ts_ui.lua index 4427a49..dca50da 100644 --- a/advtrains_interlocking/tcb_ts_ui.lua +++ b/advtrains_interlocking/tcb_ts_ui.lua @@ -605,12 +605,22 @@ function advtrains.interlocking.show_signalling_form(sigd, pname, sel_rte) if hasprivs then form = form.."button[3.5,7;2,1;editroute;Edit]" end + else + if tcbs.ars_disabled then + form = form.."label[0.5,6 ;NOTE: ARS is disabled.]" + form = form.."label[0.5,6.5;Routes are not automatically set.]" + end end if hasprivs then form = form.."button[0.5,8;2.5,1;newroute;New Route]" form = form.."button[ 3,8;2.5,1;unassign;Unassign Signal]" form = form.."button[ 3,9;2.5,1;influp;Influence Point]" end + if tcbs.ars_disabled then + form = form.."button[0.5,9;2.5,1;arsenable;Enable ARS]" + else + form = form.."button[0.5,9;2.5,1;arsdisable;Disable ARS]" + end elseif sigd_equal(tcbs.route_origin, sigd) then -- something has gone wrong: tcbs.routeset should have been set... form = form.."label[0.5,2.5;Inconsistent state: route_origin is same TCBS but no route set. Try again.]" @@ -672,6 +682,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) tcbs.signal_name = fields.name end if tcbs.routeset and fields.cancelroute then + if tcbs.routes[tcbs.routeset] and tcbs.routes[tcbs.routeset].ars then + tcbs.ars_disabled = true + end -- if route committed, cancel route ts info ilrs.update_route(sigd, tcbs, nil, true) end @@ -720,6 +733,13 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) return end + if tcbs.ars_disabled and fields.arsenable then + tcbs.ars_disabled = nil + end + if not tcbs.ars_disabled and fields.arsdisable then + tcbs.ars_disabled = true + end + if fields.auto then tcbs.route_auto = true end -- cgit v1.2.3