Module:Cenrail: Difference between revisions
Jump to navigation
Jump to search
add date formating |
Cleanup part 1 |
||
| Line 1: | Line 1: | ||
local _m = {} | local _m = {} | ||
local | local data = mw.loadJsonData "Data:NguhRoutes/network.json" | ||
local function | local find_when = function (predicate, list) | ||
for i, v in ipairs(list) do | |||
if predicate(i, v) then | |||
return i, v | |||
end | |||
end | |||
end | end | ||
_m. | _m.line_table = function (frame) | ||
local | local linecode = frame.args[1] or frame.args.code or "CE" | ||
local | local dim = linecode:sub(1,2) == "N-" and "the_nether" or "overworld" | ||
local _, line = find_when(function(_, v) return v.code == linecode end, data.lines[dim]) | |||
local out = "{|\n" | |||
out = out .. "|+ " .. line.name .. " [" .. line.code .. "]\n" | |||
out = out .. "|-" | |||
return out | |||
return | |||
end | end | ||
return _m | return _m | ||
Revision as of 12:44, 19 October 2025
Documentation for this module may be created at Module:Cenrail/doc
local _m = {}
local data = mw.loadJsonData "Data:NguhRoutes/network.json"
local find_when = function (predicate, list)
for i, v in ipairs(list) do
if predicate(i, v) then
return i, v
end
end
end
_m.line_table = function (frame)
local linecode = frame.args[1] or frame.args.code or "CE"
local dim = linecode:sub(1,2) == "N-" and "the_nether" or "overworld"
local _, line = find_when(function(_, v) return v.code == linecode end, data.lines[dim])
local out = "{|\n"
out = out .. "|+ " .. line.name .. " [" .. line.code .. "]\n"
out = out .. "|-"
return out
end
return _m