aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/trainhud.lua9
-rw-r--r--advtrains/trainlogic.lua3
-rw-r--r--advtrains/wagons.lua35
3 files changed, 42 insertions, 5 deletions
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
index f326427..9ea7466 100644
--- a/advtrains/trainhud.lua
+++ b/advtrains/trainhud.lua
@@ -161,8 +161,9 @@ function advtrains.hud_train_format(train, flip)
local fct=flip and -1 or 1
if not train then return "" end
- local max=train.max_speed or 10
- local vel=advtrains.abs_ceil(train.velocity)
+ local max = train.max_speed or 10
+ local res = train.speed_restriction or max
+ local vel = advtrains.abs_ceil(train.velocity)
local vel_kmh=advtrains.abs_ceil(advtrains.ms_to_kmh(train.velocity))
local levers = "B - o +"
@@ -184,7 +185,7 @@ function advtrains.hud_train_format(train, flip)
if train.atc_brake_target then
b="-B-"
end
- secondLine="ATC"..b..": |"..string.rep("+", tvel)..string.rep("_", max-tvel).."> "..tvel_kmh.." km/h"
+ 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"
else
@@ -195,7 +196,7 @@ function advtrains.hud_train_format(train, flip)
end
topLine=" ["..mletter[fct].."] {"..levers.."} "..doorstr[(train.door_open or 0) * fct]
- firstLine=attrans("Speed:").." |"..string.rep("+", vel)..string.rep("_", max-vel).."> "..vel_kmh.." km/h"
+ firstLine=attrans("Speed:").." |"..string.rep("+", vel)..string.rep("_", res-vel).."|"..string.rep("_", max-res).."> "..vel_kmh.." km/h"
return (train.debug or "").."\n"..topLine.."\n"..firstLine.."\n"..secondLine
end
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index 7147787..f94bda0 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -1027,6 +1027,9 @@ function advtrains.invert_train(train_id)
table.insert(train.trainparts, 1, v)--notice insertion at first place
end
advtrains.update_trainpart_properties(train_id, true)
+
+ -- TODO: this should actually be SHUNT_MAX_SPEED, but signals and lzb is not present everywhere
+ advtrains.speed_restriction = nil
end
-- returns: train id, index of one of the trains that stand at this position.
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 9cf6cc4..c69b5e6 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -840,7 +840,23 @@ function wagon:show_bordcom(pname)
else
form=form.."label[0.5,4.5;Train overview / coupling control is only shown when the train stands.]"
end
- form = form .. "button[0.5,8;3,1;Save;save]"
+ form = form .. "button[0.5,8;3,1;save;Save]"
+
+ -- Interlocking functionality: If the interlocking module is loaded, you can set the signal aspect
+ -- from inside the train
+ if 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.pos then
+ if advtrains.interlocking.db.get_sigd_for_signal(oci.pos) then
+ form = form .. "button[4.5,8;5,1;ilrs;Remote Routesetting]"
+ break
+ end
+ end
+ i=i+1
+ end
+ end
minetest.show_formspec(pname, "advtrains_bordcom_"..self.id, form)
end
@@ -924,6 +940,23 @@ function wagon:handle_bordcom_fields(pname, formname, fields)
train.couple_lck_back=false
end
+ -- 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.pos then
+ local sigd = advtrains.interlocking.db.get_sigd_for_signal(oci.pos)
+ if sigd then
+ advtrains.interlocking.show_signalling_form(sigd, pname)
+ return
+ end
+ end
+ i=i+1
+ end
+ end
+
if not fields.quit then
self:show_bordcom(pname)