aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-11-20 11:57:46 +0100
committerorwell96 <orwell@bleipb.de>2018-11-20 11:57:46 +0100
commit37166b5c142b6b3578e589b75b86d2e11345f49d (patch)
treea3f09325dbe4c141d277c11c7a9016a6b711e1bb /advtrains
parent8b80742fa5b21392999dbe6a3d259d57068899f3 (diff)
downloadadvtrains-37166b5c142b6b3578e589b75b86d2e11345f49d.tar.gz
advtrains-37166b5c142b6b3578e589b75b86d2e11345f49d.tar.bz2
advtrains-37166b5c142b6b3578e589b75b86d2e11345f49d.zip
Make "Line" property accessible from OBC and gettable via LATC, change subway wagon texture handling
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/trainhud.lua2
-rw-r--r--advtrains/wagons.lua30
2 files changed, 15 insertions, 17 deletions
diff --git a/advtrains/trainhud.lua b/advtrains/trainhud.lua
index 0175410..407518f 100644
--- a/advtrains/trainhud.lua
+++ b/advtrains/trainhud.lua
@@ -202,7 +202,7 @@ function advtrains.hud_train_format(train, flip)
secondLine = "-!- Safety override -!-"
end
- topLine=" ["..mletter[fct].."] {"..levers.."} "..doorstr[(train.door_open or 0) * fct]
+ topLine=" ["..mletter[fct].."] {"..levers.."} "..doorstr[(train.door_open or 0) * fct].." "..(train.line and "L: "..train.line or "")
firstLine=attrans("Speed:").." |"..string.rep("+", vel)..string.rep("_", res-vel).."|"..string.rep("_", max-res).."> "..vel_kmh.." km/h"
if train.speed_restriction == 0 then
firstLine = "OVERRUN RED SIGNAL! Examine situation and reverse train to move again."
diff --git a/advtrains/wagons.lua b/advtrains/wagons.lua
index 10b0941..0a4f217 100644
--- a/advtrains/wagons.lua
+++ b/advtrains/wagons.lua
@@ -235,10 +235,12 @@ function wagon:on_step(dtime)
if not self.seatpc then
self.seatpc={}
end
+
+ local train=self:train()
--custom on_step function
if self.custom_on_step then
- self:custom_on_step(self, dtime)
+ self:custom_on_step(dtime, data, train)
end
--driver control
@@ -298,12 +300,12 @@ function wagon:on_step(dtime)
end
--check infotext
- local outside=self:train().text_outside or ""
+ local outside=train.text_outside or ""
if setting_show_ids then
outside = outside .. "\nT:" .. data.train_id .. " W:" .. self.id .. " O:" .. data.owner
end
- local train=self:train()
+
--show off-track information in outside text instead of notifying the whole server about this
if train.off_track then
outside = outside .."\n!!! Train off track !!!"
@@ -315,19 +317,7 @@ function wagon:on_step(dtime)
end
local fct=data.wagon_flipped and -1 or 1
- --set line number
- if self.name == "advtrains:subway_wagon" and train.line and train.line~=self.line_cache then
- local new_line_tex="advtrains_subway_wagon.png^advtrains_subway_wagon_line"..train.line..".png"
- self.object:set_properties({
- textures={new_line_tex},
- })
- self.line_cache=train.line
- elseif self.line_cache~=nil and train.line==nil then
- self.object:set_properties({
- textures=self.textures,
- })
- self.line_cache=nil
- end
+
--door animation
if self.doors then
if (self.door_anim_timer or 0)<=0 then
@@ -779,6 +769,7 @@ function wagon:show_bordcom(pname)
local form = "size[11,9]label[0.5,0;AdvTrains Boardcom v0.1]"
form=form.."textarea[0.5,1.5;7,1;text_outside;"..attrans("Text displayed outside on train")..";"..(train.text_outside or "").."]"
form=form.."textarea[0.5,3;7,1;text_inside;"..attrans("Text displayed inside train")..";"..(train.text_inside or "").."]"
+ form=form.."field[7.5,3.2;2,1;line;"..attrans("Line")..";"..(train.line or "").."]"
--row 5 : train overview and autocoupling
if train.velocity==0 then
form=form.."label[0.5,4.5;Train overview /coupling control:]"
@@ -864,6 +855,13 @@ function wagon:handle_bordcom_fields(pname, formname, fields)
train.text_inside=nil
end
end
+ if fields.line then
+ if fields.line~="" then
+ train.line=fields.line
+ else
+ train.line=nil
+ end
+ end
for i, tpid in ipairs(train.trainparts) do
if fields["dcpl_"..i] then
advtrains.safe_decouple_wagon(tpid, pname)