aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains/trainhud.lua18
-rw-r--r--advtrains/trainlogic.lua11
-rw-r--r--advtrains_interlocking/lzb.lua18
3 files changed, 33 insertions, 14 deletions
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
index d880ffc..6332c47 100644
--- a/advtrains/trainhud.lua
+++ b/advtrains/trainhud.lua
@@ -61,6 +61,7 @@ function advtrains.on_control_change(pc, train, flip)
act=true
else
advtrains.invert_train(train.id)
+ advtrains.atc.train_reset_command(train)
end
end
if pc.left then
@@ -178,16 +179,21 @@ function advtrains.hud_train_format(train, flip)
local topLine, firstLine
local secondLine
- if train.tarvelocity then
+ if train.tarvelocity or train.atc_command then
local b=" "
- local tvel=advtrains.abs_ceil(train.tarvelocity)
- local tvel_kmh=advtrains.abs_ceil(advtrains.ms_to_kmh(train.tarvelocity))
+ local tvels=""
+ if train.tarvelocity then
+ local tvel = advtrains.abs_ceil(train.tarvelocity)
+ tvels = "|"..string.rep("+", tvel)..string.rep("_", max-tvel)
+ end
if train.atc_brake_target then
b="-B-"
end
- secondLine="ATC"..b..": |"..string.rep("+", tvel)..string.rep("_", max-tvel).." > "..tvel_kmh.." km/h"
- elseif train.atc_delay then
- secondLine = "ATC waiting "..advtrains.abs_ceil(train.atc_delay).."s"
+ local ad = ""
+ if train.atc_delay then
+ ad = " "..advtrains.abs_ceil(train.atc_delay).."s "
+ end
+ secondLine="ATC"..b..": "..tvels..ad..(train.atc_command or "")
else
secondLine = "Manual operation"
end
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 6d903c5..15d8871 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -329,7 +329,6 @@ function advtrains.train_step_b(id, train, dtime)
--interpret ATC command and apply auto-lever control when not actively controlled
local trainvelocity = train.velocity
-
if train.ctrl.user then
advtrains.atc.train_reset_command(train)
else
@@ -343,16 +342,16 @@ function advtrains.train_step_b(id, train, dtime)
train.atc_brake_target=nil
braketar = nil
end
- if train.tarvelocity and train.velocity==train.tarvelocity then
- train.tarvelocity = nil
- end
+ --if train.tarvelocity and train.velocity==train.tarvelocity then
+ -- train.tarvelocity = nil
+ --end
if train.atc_wait_finish then
- if not train.atc_brake_target and not train.tarvelocity then
+ if not train.atc_brake_target and (not train.tarvelocity or train.velocity==train.tarvelocity) then
train.atc_wait_finish=nil
end
end
if train.atc_command then
- if 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 then
advtrains.atc.execute_atc_command(id, train)
else
train.atc_delay=train.atc_delay-dtime
diff --git a/advtrains_interlocking/lzb.lua b/advtrains_interlocking/lzb.lua
index db745ef..54b1a7a 100644
--- a/advtrains_interlocking/lzb.lua
+++ b/advtrains_interlocking/lzb.lua
@@ -30,7 +30,9 @@ local AWARE_ZONE = 50
local ADD_STAND = 2
local ADD_SLOW = 1
-local ADD_FAST = 10
+local ADD_FAST = 7
+local ZONE_ROLL = 2
+local ZONE_HOLD = 5 -- added on top of ZONE_ROLL
local SHUNT_SPEED_MAX = 4
@@ -49,7 +51,7 @@ local function look_ahead(id, train)
local travwspd = lzb.travwspd
local lspd
- train.debug = lspd
+ --train.debug = lspd
while trav <= brake_i and (not lspd or lspd>0) do
trav = trav + 1
@@ -172,6 +174,18 @@ local function apply_control(id, train)
--train.debug = train.debug .. "BRAKE!!!"
return
end
+ i = advtrains.path_get_index_by_offset(train, i, -ZONE_ROLL)
+ if i <= train.index then
+ -- roll control
+ train.ctrl.lzb = 2
+ return
+ end
+ i = advtrains.path_get_index_by_offset(train, i, -ZONE_HOLD)
+ if i <= train.index then
+ -- hold speed
+ train.ctrl.lzb = 3
+ return
+ end
end
end
train.ctrl.lzb = nil