Module:Sandbox/PhiH/Route

From English Wikipedia @ Freddythechick

This is the current revision of this page, as edited by imported>Gonnym at 08:34, 26 March 2024 (Gonnym moved page Module:User:PhiH/Route to Module:Sandbox/PhiH/Route: correct name for user sandboxes). The present address (URL) is a permanent link to this version.

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

local p = {} 
function p.route(frame)
    local route = frame.args.route
    local inv = frame.args.inv
    local station = frame.args.station
    local listall = frame.args.listall
    local ilist = mw.text.split(route, '\n')
    local output = ''
    
    local list = {}
    if not (int == '') then
    	for i, v in ipairs(ilist) do
    		list[#ilist - i + 1] = v
    	end
    else list = ilist end
    
    for i, v in ipairs(list) do
    	local entry = mw.text.split(v, '\\')
    	if (entry[1] == station) then output = output .. '–\'\'\'' .. v .. '\'\'\''
    	elseif (#entry == 1 or entry[2] == 'M') and not (listall == '') then
    		if not (i == 1) then output = output .. ' – ' end
    	    output = output .. stnlnk(entry[1], entry[3])
        end
    end
    return output
end

function p.stnlnk(frame)
    local station = frame.args[1]
	local link = frame.args[2]
	return stnlnk(station, link)
end

function stnlnk(station, link)
	if link == nil then link = station .. ' railway station' end
	return '[[' .. link .. '|' .. station .. ']]' 
end
return p