aboutsummaryrefslogtreecommitdiff
path: root/advtrains/trainlogic.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-10-25 19:54:58 +0200
committerorwell96 <orwell@bleipb.de>2021-10-25 21:04:45 +0200
commite7d0a5fac2d87b468199059f1dd5bffb8bbcb327 (patch)
treedb00d286344d4f1995162d6255f79a053b80b44d /advtrains/trainlogic.lua
parent4989da3663cbc91ccd283a20f40bb4031687aacf (diff)
downloadadvtrains-e7d0a5fac2d87b468199059f1dd5bffb8bbcb327.tar.gz
advtrains-e7d0a5fac2d87b468199059f1dd5bffb8bbcb327.tar.bz2
advtrains-e7d0a5fac2d87b468199059f1dd5bffb8bbcb327.zip
Train Coupling: Change behavior so that train direction of initiating train is kept, add ATC Cpl command
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r--advtrains/trainlogic.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 00c04bf..4650f9e 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -418,9 +418,11 @@ function advtrains.train_step_b(id, train, dtime)
ctrl_lever = userc
else
if train.atc_command then
- if (not train.atc_delay or train.atc_delay<=0) and not train.atc_wait_finish then
+ if (not train.atc_delay or train.atc_delay<=0)
+ and not train.atc_wait_finish
+ and not train.atc_wait_autocouple then
advtrains.atc.execute_atc_command(id, train)
- else
+ elseif train.atc_delay and train.atc_delay > 0 then
train.atc_delay=train.atc_delay-dtime
end
elseif train.atc_delay then
@@ -711,12 +713,15 @@ function advtrains.train_step_c(id, train, dtime)
if train.ontrack_collision_info then
train.velocity = 0
train.acceleration = 0
- advtrains.atc.train_reset_command(train)
+ --advtrains.atc.train_reset_command(train) will occur in couple_initiate_with if required
local otrn = advtrains.trains[train.ontrack_collision_info.otid]
if otrn.velocity == 0 then -- other train must be standing, else don't initiate coupling
advtrains.couple_initiate_with(train, otrn, not train.ontrack_collision_info.same_dir)
+ else
+ -- other collision - stop any ATC control
+ advtrains.atc.train_reset_command(train)
end
train.ontrack_collision_info = nil