Module:Station: Difference between revisions

From Nguhcraft Wiki
Jump to navigation Jump to search
Biangfox (talk | contribs)
No edit summary
Biangfox (talk | contribs)
No edit summary
 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
p.simple = function(frame)
local p = {}
    local code = frame.args[1] or "KCC"
 
    local station = findStation(code)
-- Load JSON data
    local servedLines = getLinesForStation(code)
local data = mw.loadJsonData("Data:Cenrail_Network")
   
 
    if not station then
p.yes = function(frame)
        return "Station " .. code .. " not found"
local rS = ""
    end
for i,j in pairs(data.stops) do rS = rS .. i .. " : " .. tostring(j) .. "\n" end
   
return rS
    local stationName = type(station) == "table" and (station[1] or station.name) or station
   
    -- Simple infobox with minimal formatting
    local wikitext = string.format([[
{{Infobox
| name = %s Station
| station_code = %s
| image =
| caption =
]], stationName, code)
   
    -- Add lines
    local count = 0
    for lineKey, lineData in pairs(servedLines) do
        count = count + 1
        wikitext = wikitext .. string.format("| line%d = %s\n", count, lineData.name)
    end
   
    wikitext = wikitext .. "}}"
   
    return wikitext
end
end
p.found = function(frame)
end
return p

Latest revision as of 17:21, 11 January 2026

Documentation for this module may be created at Module:Station/doc

local p = {}

-- Load JSON data
local data = mw.loadJsonData("Data:Cenrail_Network")

p.yes = function(frame)
	local rS = ""
	for i,j in pairs(data.stops) do rS = rS .. i .. " : " .. tostring(j) .. "\n" end 
	return rS 
end

p.found = function(frame) 
end

return p