aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2020-04-28 16:01:35 +0200
committerorwell96 <orwell@bleipb.de>2021-02-10 16:36:24 +0100
commit8660794ef8392f08fa5be46715abb5dcbd96ca5d (patch)
treef077c3f12f901ed41061ee2672c62d53d5d2c27e /advtrains_luaautomation
parent5c2534cc35bc0fc47b53c8a992e3e71b15a60ec4 (diff)
downloadadvtrains-8660794ef8392f08fa5be46715abb5dcbd96ca5d.tar.gz
advtrains-8660794ef8392f08fa5be46715abb5dcbd96ca5d.tar.bz2
advtrains-8660794ef8392f08fa5be46715abb5dcbd96ca5d.zip
Fix lots of things around new LZB
Diffstat (limited to 'advtrains_luaautomation')
-rw-r--r--advtrains_luaautomation/README.txt4
-rw-r--r--advtrains_luaautomation/atc_rail.lua4
2 files changed, 5 insertions, 3 deletions
diff --git a/advtrains_luaautomation/README.txt b/advtrains_luaautomation/README.txt
index 3e9a257..7c064cc 100644
--- a/advtrains_luaautomation/README.txt
+++ b/advtrains_luaautomation/README.txt
@@ -247,8 +247,10 @@ set_shunt(), unset_shunt()
-- This additional function is available when advtrains_interlocking is enabled: --
-atc_set_disable_ars(true)
+atc_set_disable_ars(boolean)
Disables (true) or enables (false) the use of ARS for this train. The train will not trigger ARS (automatic route setting) on signals then.
+ Note: If you want to disable ARS from an approach callback, the call to atc_set_disable_ars(true) must happen during the approach callback,
+ and may not be deferred to an interrupt(). Else the train might trigger an ARS before the interrupt fires.
# 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 0f5a7dc..6ce323d 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -199,7 +199,7 @@ advtrains.register_tracks("default", {
--do async. Event is fired in train steps
atlatc.interrupt.add(0, pos, {type="train", train=true, id=train_id})
end,
- on_train_approach = function(pos, train_id, train, index, lzbdata)
+ on_train_approach = function(pos, train_id, train, index, has_entered, lzbdata)
-- Insert an event only if the rail indicated that it supports approach callbacks
local ph=minetest.pos_to_string(pos)
local railtbl = atlatc.active.nodes[ph]
@@ -208,7 +208,7 @@ advtrains.register_tracks("default", {
if railtbl and railtbl.data and railtbl.data.__approach_callback_mode then
local acm = railtbl.data.__approach_callback_mode
if acm==2 or (acm==1 and train.path_cn[index] == 1) then
- local evtdata = {type="approach", approach=true, id=train_id}
+ local evtdata = {type="approach", approach=true, id=train_id, has_entered = has_entered}
-- This event is *required* to run synchronously, because it might set the ars_disable flag on the train and add LZB checkpoints,
-- although this is generally discouraged because this happens right in a train step
-- At this moment, I am not aware whether this may cause side effects, and I must encourage users not to do expensive calculations here.