Remote Routesetting from Onboard Computer

+ Fix lzb oncoming item deletion/speed restriction
master
orwell96 2018-10-10 23:17:31 +02:00
parent 842a85606e
commit 9db52bcd32
4 changed files with 43 additions and 6 deletions

View File

@ -162,6 +162,7 @@ function advtrains.hud_train_format(train, flip)
if not train then return "" end
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))
@ -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

View File

@ -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.

View File

@ -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)

View File

@ -138,7 +138,7 @@ local function apply_control(id, train)
local lzb = train.lzb
local i = 1
while i<#lzb.oncoming do
while i<=#lzb.oncoming do
if lzb.oncoming[i].idx < train.index then
train.speed_restriction = lzb.oncoming[i].spd
table.remove(lzb.oncoming, i)