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
|
@ -98,23 +98,46 @@ 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
|
||||
end
|
||||
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")
|
||||
|
||||
|
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 900 B After Width: | Height: | Size: 842 B |
After Width: | Height: | Size: 155 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 222 B |
After Width: | Height: | Size: 166 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 218 B |
After Width: | Height: | Size: 172 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 229 B |
After Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 219 B |
After Width: | Height: | Size: 168 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 237 B |
After Width: | Height: | Size: 169 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 174 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 233 B |
After Width: | Height: | Size: 169 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 218 B |
After Width: | Height: | Size: 167 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 173 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 239 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 170 B |
After Width: | Height: | Size: 171 B |
After Width: | Height: | Size: 165 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 171 B |
After Width: | Height: | Size: 171 B |
After Width: | Height: | Size: 166 B |
After Width: | Height: | Size: 167 B |
After Width: | Height: | Size: 171 B |
After Width: | Height: | Size: 26 KiB |