aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-01-15 15:38:17 +0100
committerorwell96 <orwell@bleipb.de>2019-01-15 15:38:17 +0100
commit12f8e26cb47f2dc365c69ff721b4c3faf348c61d (patch)
tree7677a32b2da0d4910cf2ed49b75ef3402f553d63 /advtrains
parenta751d1da9c57a40a0df4e8793a1cc46cb7985e12 (diff)
downloadadvtrains-12f8e26cb47f2dc365c69ff721b4c3faf348c61d.tar.gz
advtrains-12f8e26cb47f2dc365c69ff721b4c3faf348c61d.tar.bz2
advtrains-12f8e26cb47f2dc365c69ff721b4c3faf348c61d.zip
Do not clear tarvelocity when setting new, potential no-op command
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/atc.lua14
1 files changed, 9 insertions, 5 deletions
diff --git a/advtrains/atc.lua b/advtrains/atc.lua
index 5adacf3..80b1b36 100644
--- a/advtrains/atc.lua
+++ b/advtrains/atc.lua
@@ -21,7 +21,7 @@ end
--general
function atc.train_set_command(train, command, arrow)
- atc.train_reset_command(train)
+ atc.train_reset_command(train, true)
train.atc_delay = 0
train.atc_arrow = arrow
train.atc_command = command
@@ -67,13 +67,17 @@ function atc.send_command(pos, par_tid)
return false
end
-function atc.train_reset_command(train)
+-- Resets any ATC commands the train is currently executing, including the target speed (tarvelocity) it is instructed to hold
+-- if keep_tarvel is set, does not clear the tarvelocity
+function atc.train_reset_command(train, keep_tarvel)
train.atc_command=nil
train.atc_delay=nil
train.atc_brake_target=nil
train.atc_wait_finish=nil
train.atc_arrow=nil
- train.tarvelocity=nil
+ if not keep_tarvel then
+ train.tarvelocity=nil
+ end
end
--nodes
@@ -261,7 +265,7 @@ function atc.execute_atc_command(id, train)
while nest>=0 do
if pos>#rest then
atwarn(sid(id), attrans("ATC command syntax error: I statement not closed: @1",command))
- atc.train_reset_command(train)
+ atc.train_reset_command(train, true)
return
end
local char=string.sub(rest, pos, pos)
@@ -304,7 +308,7 @@ function atc.execute_atc_command(id, train)
end
end
atwarn(sid(id), attrans("ATC command parse error: Unknown command: @1", command))
- atc.train_reset_command(train)
+ atc.train_reset_command(train, true)
end