aboutsummaryrefslogtreecommitdiff
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
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
-rw-r--r--advtrains/trainhud.lua2
-rw-r--r--advtrains/wagons.lua30
-rw-r--r--advtrains_luaautomation/README.txt8
-rw-r--r--advtrains_luaautomation/atc_rail.lua10
-rw-r--r--advtrains_train_subway/init.lua20
-rw-r--r--advtrains_train_subway/textures/advtrains_subway_wagon_line0.png (renamed from advtrains_train_subway/textures/advtrains_subway_wagon_line10.png)bin1224 -> 1224 bytes
6 files changed, 50 insertions, 20 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)
diff --git a/advtrains_luaautomation/README.txt b/advtrains_luaautomation/README.txt
index 279b07d..2963192 100644
--- a/advtrains_luaautomation/README.txt
+++ b/advtrains_luaautomation/README.txt
@@ -173,8 +173,14 @@ atc_set_text_outside(text)
Set text shown on the outside of the train. Pass nil to show no text.
atc_set_text_inside(text)
Set text shown to train passengers. Pass nil to show no text.
+get_line()
+ Returns the "Line" property of the train (a string).
+ This can be used to distinguish between trains of different lines and route them appropriately.
+ The interlocking system also uses this property for Automatic Routesetting.
set_line(number)
- Only for subway wagons: Display a line number (1-9) on the train.
+ Sets the "Line" property of the train (a string).
+ If the first digit of this string is a number (0-9), any subway wagons on the train will have this one displayed as line number
+ (where "0" is actually shown as Line 10 on the train)
# Operator panel
This simple node executes its actions when punched. It can be used to change a switch and update the corresponding signals or similar applications.
diff --git a/advtrains_luaautomation/atc_rail.lua b/advtrains_luaautomation/atc_rail.lua
index 1fab620..6a3959c 100644
--- a/advtrains_luaautomation/atc_rail.lua
+++ b/advtrains_luaautomation/atc_rail.lua
@@ -54,8 +54,14 @@ function r.fire_event(pos, evtdata)
return true
end,
set_line = function(line)
- train.line = line
- return true
+ if type(line)~="string" and type(line)~="number" then
+ return false
+ end
+ train.line = line .. ""
+ return true
+ end,
+ get_line = function()
+ return train.line
end,
atc_reset = function(cmd)
if not train_id then return false end
diff --git a/advtrains_train_subway/init.lua b/advtrains_train_subway/init.lua
index 62bcc41..c1a50e2 100644
--- a/advtrains_train_subway/init.lua
+++ b/advtrains_train_subway/init.lua
@@ -101,6 +101,26 @@ advtrains.register_wagon("subway_wagon", {
self.sound_loop_tmr=0
end
end,
+ custom_on_step = function(self, dtime, data, train)
+ --set line number
+ local line = nil
+ if train.line then
+ line = tonumber(string.sub(train.line, 1, 1))
+ end
+ if line and line~=self.line_cache then
+ local new_line_tex="advtrains_subway_wagon.png^advtrains_subway_wagon_line"..line..".png"
+ self.object:set_properties({
+ textures={new_line_tex},
+ })
+ self.line_cache=line
+ elseif self.line_cache~=nil and line==nil then
+ atdebug("clear line")
+ self.object:set_properties({
+ textures=self.textures,
+ })
+ self.line_cache=nil
+ end
+ end,
}, S("Subway Passenger Wagon"), "advtrains_subway_wagon_inv.png")
--wagons
diff --git a/advtrains_train_subway/textures/advtrains_subway_wagon_line10.png b/advtrains_train_subway/textures/advtrains_subway_wagon_line0.png
index c656d97..c656d97 100644
--- a/advtrains_train_subway/textures/advtrains_subway_wagon_line10.png
+++ b/advtrains_train_subway/textures/advtrains_subway_wagon_line0.png
Binary files differ