aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains/atc.lua5
-rw-r--r--advtrains/init.lua3
-rw-r--r--advtrains/wagons.lua28
-rw-r--r--advtrains_interlocking/approach.lua19
-rw-r--r--advtrains_line_automation/stoprail.lua3
-rw-r--r--advtrains_luaautomation/README.txt5
-rw-r--r--advtrains_luaautomation/atc_rail.lua7
-rw-r--r--advtrains_luaautomation/passive_api.txt2
-rw-r--r--atc_command.txt13
9 files changed, 66 insertions, 19 deletions
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
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
diff --git a/advtrains_line_automation/stoprail.lua b/advtrains_line_automation/stoprail.lua
index dfc9b0c..5af4399 100644
--- a/advtrains_line_automation/stoprail.lua
+++ b/advtrains_line_automation/stoprail.lua
@@ -184,6 +184,7 @@ local adefunc = function(def, preset, suffix, rotation)
local stn = advtrains.lines.stations[stdata.stn]
local stnname = stn and stn.name or "Unknown Station"
train.text_inside = "Next Stop:\n"..stnname
+ advtrains.interlocking.ars_set_disable(train, true)
end
end
end
@@ -201,7 +202,7 @@ local adefunc = function(def, preset, suffix, rotation)
local stnname = stn and stn.name or "Unknown Station"
-- Send ATC command and set text
- advtrains.atc.train_set_command(train, "B0 W O"..stdata.doors..(stdata.kick and "K" or "").." D"..stdata.wait.." OC "..(stdata.reverse and "R" or "").."D"..(stdata.ddelay or 1) .. "S" ..(stdata.speed or "M"), true)
+ advtrains.atc.train_set_command(train, "B0 W O"..stdata.doors..(stdata.kick and "K" or "").." D"..stdata.wait.." OC "..(stdata.reverse and "R" or "").."D"..(stdata.ddelay or 1) .. " A1 S" ..(stdata.speed or "M"), true)
train.text_inside = stnname
if tonumber(stdata.wait) then
minetest.after(tonumber(stdata.wait), function() train.text_inside = "" end)
diff --git a/advtrains_luaautomation/README.txt b/advtrains_luaautomation/README.txt
index b565360..3e9a257 100644
--- a/advtrains_luaautomation/README.txt
+++ b/advtrains_luaautomation/README.txt
@@ -245,6 +245,11 @@ unset_autocouple()
set_shunt(), unset_shunt()
deprecated aliases for set_autocouple() and unset_autocouple(), will be removed from a later release.
+-- This additional function is available when advtrains_interlocking is enabled: --
+
+atc_set_disable_ars(true)
+ Disables (true) or enables (false) the use of ARS for this train. The train will not trigger ARS (automatic route setting) on signals then.
+
# Approach callbacks
The LuaATC interface provides a way to hook into the approach callback system, which is for example used in the TSR rails (provided by advtrains_interlocking) or the station tracks (provided by advtrains_lines). However, for compatibility reasons, this behavior needs to be explicitly enabled.
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index 33b5d00..0f5a7dc 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -153,6 +153,7 @@ function r.fire_event(pos, evtdata, appr_internal)
if not appr_internal then
error("atc_set_lzb_tsr() can only be used during 'approach' events!")
end
+ assert(tonumber(speed), "Number expected!")
local index = appr_internal.index
advtrains.lzb_add_checkpoint(train, index, speed, nil)
@@ -160,6 +161,12 @@ function r.fire_event(pos, evtdata, appr_internal)
return true
end,
}
+ -- interlocking specific
+ if advtrains.interlocking then
+ customfct.atc_set_ars_disable = function(value)
+ advtrains.interlocking.ars_set_disable(train, value)
+ end
+ end
atlatc.active.run_in_env(pos, evtdata, customfct)
diff --git a/advtrains_luaautomation/passive_api.txt b/advtrains_luaautomation/passive_api.txt
index 9852e94..5ae1df4 100644
--- a/advtrains_luaautomation/passive_api.txt
+++ b/advtrains_luaautomation/passive_api.txt
@@ -7,7 +7,7 @@ Displays
Mesecon Transmitter
Those passive components can also be used inside interlocking systems.
-All passive components have a table called 'advtrains' in their node definition and have the group 'save_in_nodedb' set, so they work in unloaded chunks.
+All passive components have a table called 'advtrains' in their node definition and have the group 'save_in_at_nodedb' set, so they work in unloaded chunks.
Example for a switch:
advtrains = {
getstate = function(pos, node)
diff --git a/atc_command.txt b/atc_command.txt
index 0acbacb..9f4eb50 100644
--- a/atc_command.txt
+++ b/atc_command.txt
@@ -72,12 +72,15 @@ If the train drives in the 'wrong' direction, stop and reverse; independently ac
I<8 S8 ;
If the train is slower than 8, accelerate to 8.
-# ATC controller operation modes
-static: Only give 1 static command.
+# Interlocking
-mesecon: Give 2 different commands depending on if the controller is mesecon-powered or not
-digiline: Don't give any commands by itself. When a train passes, a digiline message in the form of "[+/-][speed]" is sent on the set channel (where +/- means the same as with conditions). Any digiline message sent to the controller will be interpreted as ATC command and sent to the train.
-** the latter two are not yet implemented.
+With advtrains_interlocking, there's one more available command:
+
+A0
+Disable ARS on the train.
+A1
+Enable ARS on the train.
+When disabled, the train will not trigger automatic route setting on signals based on ARS.
# Persistence
ATC controllers that are configured as 'static' or 'mesecon' are persistent over mapblock unloads and will even command the train when the mapblock is unloaded. This is not possible with digilines since these do not work in unloaded mapchunks.