![]() | Please do not delete this module or its doc page. |
Parameters
(floor#)
- Sets the name of a floor
(floor#)_(part#)_(param)
- Sets a parameter for a row of a floor where (param)
is:
name
- The name of the row, e.g. "Westbound track"desc
- The description for the row- Services
dir
- The direction of the service(s) for the track (right
orleft
)service
- The service running on the trackservice(service#)
- Additional services running on the trackdest
- The destination for the servicedest(service#)
- Destinations for the additional servicesnote
- Note about the servicesnote(service#)
- Notes about the additional services
- Platform
platform
- The type of platformaccessible
- Set if the platform isaccessible
note
- Note about the platform
-- Sandbox, do not delete
require('strict')
local p = {}
local function displayFloorPart(floorPart)
if floorPart.name then
return floorPart.name .. ' ' .. floorPart.desc
elseif floorPart.dir then
return floorPart.dir .. ' ' .. floorPart.desc
else
return 'Invalid floor part! Must have either <code>x_y_name</code> or <code>x_y_dir</code>.'
end
end
local function displayFloor(stationFloor, number)
local out = ''
out = out .. stationFloor.letter
for i = 1, stationFloor.max do
out = out .. displayFloorPart(stationFloor[i])
end
return out
end
local function processArg(out, level, levelPart, param, value)
local level = tonumber(level)
local levelPart = tonumber(levelPart)
if level > out.max then
out.max = level
end
if not out[level] then
out[level] = { max = 0 }
end
if levelPart > out[level].max then
out[level].max = levelPart
end
if not out[level][levelPart] then
out[level][levelPart] = {}
end
out[level][levelPart][param] = value
end
local function processArgs(args)
local out = { max = 0 }
for i, v in pairs(args) do
if type(i) == 'number' then
local level = tonumber(i)
if not out[level] then
out[level] = { max = 0 }
end
out[level].letter = v
else
local level, levelPart, param = i:match('(%d+)_(%d+)_(.+)')
if level then
processArg(out, level, levelPart, param, v)
end
end
end
return out
end
function p.main(frame)
local sortedArgs = processArgs(frame.args)
local out = ''
for i = 1, sortedArgs.max do
out = out .. displayFloor(sortedArgs[i], i)
end
return out
end
return p