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/atc.lua | 5 +++++ advtrains/init.lua | 3 ++- advtrains/wagons.lua | 28 ++++++++++++++++++---------- 3 files changed, 25 insertions(+), 11 deletions(-) (limited to 'advtrains') diff --git a/advtrains/atc.lua b/advtrains/atc.lua index 2fa3929..1c6df36 100644 --- a/advtrains/atc.lua +++ b/advtrains/atc.lua @@ -256,6 +256,11 @@ local matchptn={ end return 1 end, + ["A([01])"]=function(id, train, match) + if not advtrains.interlocking then return 2 end + advtrains.interlocking.ars_set_disable(train, match=="0") + return 2 + end, } eval_conditional = function(command, arrow, speed) diff --git a/advtrains/init.lua b/advtrains/init.lua index 6e622e5..f61701c 100644 --- a/advtrains/init.lua +++ b/advtrains/init.lua @@ -464,7 +464,8 @@ advtrains.avt_save = function(remove_players_from_wagons) "trainparts", "recently_collided_with_env", "atc_brake_target", "atc_wait_finish", "atc_command", "atc_delay", "door_open", "text_outside", "text_inside", "line", "routingcode", - "il_sections", "speed_restriction", "is_shunt", "points_split", "autocouple" + "il_sections", "speed_restriction", "is_shunt", + "points_split", "autocouple", "ars_disable", }) --then save it tmp_trains[id]=v diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua index 1c663fe..522b649 100644 --- a/advtrains/wagons.lua +++ b/advtrains/wagons.lua @@ -999,6 +999,9 @@ function wagon:show_bordcom(pname) end i=i+1 end + if train.ars_disable then + form = form .. "button[4.5,7;5,1;ilarsenable;Clear 'Disable ARS' flag]" + end end minetest.show_formspec(pname, "advtrains_bordcom_"..self.id, form) @@ -1071,18 +1074,23 @@ function wagon:handle_bordcom_fields(pname, formname, fields) -- Interlocking functionality: If the interlocking module is loaded, you can set the signal aspect -- from inside the train - if fields.ilrs and advtrains.interlocking and train.lzb and #train.lzb.oncoming > 0 then - local i=1 - while train.lzb.oncoming[i] do - local oci = train.lzb.oncoming[i] - if oci.udata and oci.udata.signal_pos then - local sigd = advtrains.interlocking.db.get_sigd_for_signal(oci.udata.signal_pos) - if sigd then - advtrains.interlocking.show_signalling_form(sigd, pname) - return + if advtrains.interlocking then + if fields.ilrs and train.lzb and #train.lzb.oncoming > 0 then + local i=1 + while train.lzb.oncoming[i] do + local oci = train.lzb.oncoming[i] + if oci.udata and oci.udata.signal_pos then + local sigd = advtrains.interlocking.db.get_sigd_for_signal(oci.udata.signal_pos) + if sigd then + advtrains.interlocking.show_signalling_form(sigd, pname) + return + end end + i=i+1 end - i=i+1 + end + if fields.ilarsenable then + advtrains.interlocking.ars_set_disable(train, false) end end -- cgit v1.2.3