subway trains: display up to two digits

Additionally, as an addition by gpcf, trains having an S as the first
letter of their LN get the number behind the S displayed as a line
number
This commit is contained in:
Hume2 2020-07-25 19:07:02 +02:00 committed by Gabriel Pérez-Cerezo
parent 7e83b718a6
commit 643d69db9c
36 changed files with 40 additions and 17 deletions

View File

@ -98,22 +98,45 @@ advtrains.register_wagon("subway_wagon", {
custom_on_step = function(self, dtime, data, train)
--set line number
local line = nil
if train.line then
local lint = string.sub(train.line, 1, 1)
line = tonumber(lint)
if lint=="X" then line="X" end
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
self.object:set_properties({
textures=self.textures,
})
self.line_cache=nil
if train.line and self.line_cache ~= train.line then
self.line_cache=train.line
local lint = train.line
if string.sub(train.line, 1, 1) == "S" then
lint = string.sub(train.line,2)
end
if string.len(lint) == 1 then
if lint=="X" then line="X" end
line = tonumber(lint)
elseif string.len(lint) == 2 then
if tonumber(lint) then
line = lint
end
end
if line then
local new_line_tex="advtrains_subway_wagon.png"
if type(line)=="number" or line == "X" then
new_line_tex = new_line_tex.."^advtrains_subway_wagon_line"..line..".png"
else
local num = tonumber(line)
local red = math.fmod(line*67+101, 255)
local green = math.fmod(line*97+109, 255)
local blue = math.fmod(line*73+127, 255)
new_line_tex = new_line_tex..string.format("^(advtrains_subway_wagon_line.png^[colorize:#%X%X%X%X%X%X)^(advtrains_subway_wagon_line%s_.png^advtrains_subway_wagon_line_%s.png", math.floor(red/16), math.fmod(red,16), math.floor(green/16), math.fmod(green,16), math.floor(blue/16), math.fmod(blue,16), string.sub(line, 1, 1), string.sub(line, 2, 2))
if red + green + blue > 512 then
new_line_tex = new_line_tex .. "^[colorize:#000)"
else
new_line_tex = new_line_tex .. ")"
end
end
self.object:set_properties({
textures={new_line_tex},
})
elseif self.line_cache~=nil and line==nil then
self.object:set_properties({
textures=self.textures,
})
self.line_cache=nil
end
end
end,
}, S("Subway Passenger Wagon"), "advtrains_subway_wagon_inv.png")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 900 B

After

Width:  |  Height:  |  Size: 842 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 219 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB