Jump to content

Module:Adjacent stations/Metro Trains Melbourne

Permanently protected module
From Wikipedia, the free encyclopedia

local melbourne = "%1 railway station, Melbourne"
local c = {
    Airport = "279FD5",
	Alamein = "152C6B", 
	Belgrave = "152C6B", 
	Craigieburn = "FFBE00",
	Cranbourne = "279FD5",
	Flemington = "95979A", 
	Frankston = "028430",	
	GlenWaverley = "152C6B",	
	Hurstbridge = "BE1014", 
	Lilydale = "152C6B",
	Mernda = "BE1014",	
	Pakenham = "279FD5",
	Sandringham = "F178AF", 
	StonyPoint = "028430",
	SuburbanRailLoop = "008746",
	Sunbury = "279FD5",
	Upfield = "FFBE00",	
	Werribee = "F178AF",	
	Williamstown = "F178AF",
	VLine = "8F1A95",
	wht = "FFFFFF",
	blk = "000000",
    Disused = "999933",
}

-- Draw top colour bar
local function topBars(barTable)
    local segments, pos = {}, 0
    local width = 100 / #barTable
    for i, colour in ipairs(barTable) do
        local start = pos
        local stop  = (i == #barTable) and 100 or (pos + width)
        segments[#segments+1] = "#" .. colour .. " " .. start .. "% " .. stop .. "%"
        pos = stop
    end
    return "background-image:linear-gradient(to right," .. table.concat(segments, ",") .. "); background-size:100% 7px; background-position:top; background-repeat:no-repeat; background-origin:border-box; background-color: white; font-size: 160%; color: black; font-family:sans-serif; text-align:center; padding: 0.45em; padding-top: calc(0.45em + 7px); white-space: nowrap; margin: 0.25em;"
end

-- Convert style2 input to draw top bar
local function styleFromNames(styleText)
	local default = "background-color: #0072CE; font-size: 160%; color: white; font-family:sans-serif; text-align:center; padding: 0.45em; white-space: nowrap; margin: 0.25em;"
    if not styleText or styleText == "" then return default end
    local cols = {}
    for part in styleText:gmatch("[^,]+") do
        local key = (part or ""):gsub("[^%w]", "")
        local hex = c[key]
        if not hex then return default end
        cols[#cols+1] = hex
    end
    return topBars(cols)
end

local p = {
	["system title"] = "[[Metro Trains Melbourne|Metro Trains]]",
	["system icon"] = "[[File:Melbourne_train_logo.svg|18px|link=Railways in Melbourne|alt=Railways in Melbourne]]",
	["system color"] = "0072ce",
    ["name format"] = setmetatable({
    	["City Loop station"] = topBars({
    		c.Mernda, 
    		c.Frankston, 
    		c.Craigieburn, 
    		c.Lilydale
    	}),
    }, {
		__index = function(_, key)
		return styleFromNames(key)
		end
    }),
	["header background color"] = "E4E4E4",
	["header text color"] = "000000",
	["station format"] = {
		"%1 railway station",
		["City Loop"] = "[[City Loop]]",
		["FS or P"] = "[[Flinders Street railway station|Flinders Street]] or [[Parliament railway station|Parliament]]",
		["SC or F"] = "[[Southern Cross railway station|Southern Cross]] or [[Flagstaff railway station|Flagstaff]]",
		["S via FS"] = "[[Sandringham railway station|Sandringham]] via [[Flinders Street railway station|Flinders Street]]",
		["W via FS"] = "[[Laverton railway station, Melbourne|Laverton]], [[Werribee railway station|Werribee]] or [[Williamstown railway station|Williamstown]] via [[Flinders Street railway station|Flinders Street]]",
		["EC via M"] = "[[Cranbourne railway station|Cranbourne]] or [[East Pakenham railway station|East Pakenham]] via [[Metro Tunnel]]",
		["S via M"] = "[[Watergardens railway station|Watergardens]] or [[Sunbury railway station, Melbourne|Sunbury]] via [[Metro Tunnel]]",
		["FS via CL"] = "[[Flinders Street railway station|Flinders Street]] via [[City Loop]]",
		["F via FS"] = "[[Frankston railway station|Frankston]] via [[Flinders Street railway station|Flinders Street]]",

		["Albion"] = melbourne,
		["Armadale"] = melbourne,
		["Arden"] = melbourne,
		["Ashburton"] = melbourne,
		["Auburn"] = melbourne,
		["Balaclava"] = melbourne,
		["Bayswater"] = melbourne,
		["Beaconsfield"] = melbourne,
		["Bell"] = melbourne,
		["Berwick"] = melbourne,
		["Blackburn"] = melbourne,
		["Box Hill"] = melbourne,
		["Broadmeadows"] = melbourne,
		["Brunswick"] = melbourne,
		["Burwood"] = melbourne,
		["Burwood (SRL)"] = "Burwood SRL station",
		["Camberwell"] = melbourne,
		["Canterbury"] = melbourne,
		["Chatham"] = melbourne,
		["Chelsea"] = melbourne,
		["Cheltenham"] = melbourne,
		["Clayton"] = melbourne,
		["Clyde"] = "Clyde railway station, Victoria",
		["Croydon"] = melbourne,
		["East Richmond"] = melbourne,
		["Eltham"] = melbourne,
		["Epping"] = melbourne,
		["Fairfield"] = melbourne,
		["Hampton"] = melbourne,
		["Hastings"] = melbourne,
		["Hawthorn"] = melbourne,
		["Ivanhoe"] = melbourne,
		["Kensington"] = melbourne,
		["Laverton"] = melbourne,
		["Malvern"] = melbourne,
		["Melton"] = melbourne,
		["Mitcham"] = melbourne,
		["Montmorency"] = melbourne,
		["Newmarket"] = melbourne,
		["Newport"] = melbourne,
		["Oak Park"] = melbourne,
		["Paisley"] = melbourne,
		["Preston"] = melbourne,
		["Richmond"] = melbourne,
		["Ringwood"] = melbourne,
		["Sandown Park"] = melbourne,
		["Seaford"] = melbourne,
		["Showgrounds"] = melbourne,
		["St Albans"] = melbourne,
		["Sunbury"] = melbourne,
		["Thomastown"] = melbourne,
		["Thornbury"] = melbourne,
		["Town Hall"] = melbourne,
		["Union"] = melbourne,
		["Upwey"] = melbourne,
		["Victoria Park"] = melbourne,
		["Windsor"] = melbourne,
	},
	["lines"] = {
		["City Circle"] = {
			["title"] = "[[City Loop|City Circle]]",
			["color"] = "000000",
			["left terminus"] = "",
			["right terminus"] = "",	
			["circular"] = true
		},
		["Alamein"] = {
			["title"] = "[[Alamein line]]",
			["color"] = c.Alamein,
			["text color"] = c.wht,
			["left terminus"] = "Flinders Street",
			["right terminus"] = "Alamein",
			["types"] = {
				["shuttle"] = {
					["title"] = "",
					["left terminus"] = "Camberwell",
					["note-mid"] = "Shuttle service",
				},
				["peak"] = {
					["title"] = "",
					["note-mid"] = "Peak only",
				},
			},
		},
		["Belgrave"] = {
			["title"] = "[[Belgrave line]]",
			["color"] = c.Belgrave,
			["text color"] = c.wht,
			["left terminus"] = "Flinders Street",
			["right terminus"] = "Belgrave",
			["types"] = {
				["shuttle"] = {
					["title"] = "",
					["left terminus"] = "Ringwood",
					["note-mid"] = "Shuttle service",
				},
			},
		},
		["Craigieburn"] = {
			["title"] = "[[Craigieburn line]]",
			["color"] = c.Craigieburn,
			["left terminus"] = "Flinders Street",
			["right terminus"] = "Craigieburn"
		},
		["Cranbourne"] = {
			["title"] = "[[Cranbourne line]]",
			["color"] = c.Cranbourne,
			["text color"] = c.wht,
			["left terminus"] = "S via M",
			["right terminus"] = "Cranbourne",
			["types"] = {
				["old"] = {
					["title"] = "",
					["left terminus"] = "Flinders Street",
					["note-mid"] = "",
				},
				["shuttle"] = {
					["title"] = "",
					["left terminus"] = "Dandenong",
					["note-mid"] = "Shuttle service",
				},
			},
		},
		["Flemington Racecourse"] = {
			["title"] = "[[Flemington Racecourse line]]",
			["color"] = c.Flemington,
			["text color"] = c.wht,
			["left terminus"] = {"Southern Cross", "Flinders Street"},
			["right terminus"] = {"Showgrounds", "Flemington Racecourse"},
		},
		["Frankston"] = {
			["title"] = "[[Frankston line]]",
			["color"] = c.Frankston,
			["text color"] = c.wht,
			["left terminus"] = "FS via CL",
			["right terminus"] = "Frankston",
		},
		["Glen Waverley"] = {
			["title"] = "[[Glen Waverley line]]",
			["color"] = c.GlenWaverley,
			["text color"] = c.wht,
			["left terminus"] = "Flinders Street",
			["right terminus"] = "Glen Waverley"
		},
		["Hurstbridge"] = {
			["title"] = "[[Hurstbridge line]]",
			["color"] = c.Hurstbridge,
			["text color"] = c.wht,
			["left terminus"] = "Flinders Street",
			["right terminus"] = "Hurstbridge",
		},
		["Lilydale"] = {
			["title"] = "[[Lilydale line]]",
			["color"] = c.Lilydale,
			["text color"] = c.wht,
			["left terminus"] = "Flinders Street",
			["right terminus"] = "Lilydale",
			["types"] = {
				["shuttle"] = {
					["title"] = "",
					["left terminus"] = "Ringwood",
					["note-mid"] = "Shuttle service",
				},
			},
		},
		["Mernda"] = {
			["title"] = "[[Mernda line]]",
			["color"] = c.Mernda,
			["text color"] = c.wht,
			["left terminus"] = "Flinders Street",
			["right terminus"] = "Mernda"
		},
		["Melbourne Airport"] = {
			["title"] = "[[Melbourne Airport Rail|Airport line]]",
			["note-mid"] = "(under construction)",
			["color"] = c.Airport,
			["text color"] = c.wht,
			["left terminus"] = "EC via M",
			["right terminus"] = "Melbourne Airport"
		},
	    ["Melton"] = {
			["title"] = "[[Melton line]]",
			["color"] = "279FD5",
			["text color"] = c.wht,
			["left terminus"] = "EC via M",
			["right terminus"] = "Melton",
		},
		["Pakenham"] = {
			["title"] = "[[Pakenham line]]",
			["color"] = c.Pakenham,
			["text color"] = c.wht,
			["left terminus"] = "S via M",
			["right terminus"] = "East Pakenham",
			["types"] = {
				["old"] = {
					["title"] = "",
					["left terminus"] = "FS via CL",
				},
			},
		},
		["Sandringham"] = {
			["title"] = "[[Sandringham line]]",
			["color"] = c.Sandringham,
			["text color"] = c.blk,
			["left terminus"] = "W via FS",
			["right terminus"] = "Sandringham"
		},
		["Stony Point"] = {
			["title"] = "[[Stony Point line]]",
			["color"] = c.StonyPoint,
			["text color"] = c.wht,
			["left terminus"] = "Frankston",
			["right terminus"] = "Stony Point"
		},
		["Suburban Rail Loop"] = {
			["title"] = "[[Suburban Rail Loop]]",
			["note-mid"] = "(under construction)",
			["color"] = c.SuburbanRailLoop,
			["text color"] = c.wht,
			["left terminus"] = "Cheltenham",
			["right terminus"] = "Werribee",
			["icon"] = "[[File:Melbourne Suburban Rail Loop logo.svg|18px|link=Suburban Rail Loop]]"
		},
		["Suburban Rail Loop East"] = {
			["title"] = "[[Suburban Rail Loop East]]",
			["note-mid"] = "(under construction)",
			["color"] = c.SuburbanRailLoop,
			["text color"] = c.wht,
			["left terminus"] = "Southland",
			["right terminus"] = "Box Hill",
			["icon"] = "[[File:Melbourne Suburban Rail Loop logo.svg|18px|link=Suburban Rail Loop]]"
		},
		["Sunbury"] = {
			["title"] = "[[Sunbury line]]",
			["color"] = c.Sunbury,
			["text color"] = c.wht,
			["left terminus"] = "EC via M",
			["right terminus"] = {"Watergardens", "Sunbury"},
			["types"] = {
				["old"] = {
					["title"] = "",
					["color"] = "FFBE00",
					["background color"] = "",
					["text color"] = c.blk,
					["left terminus"] = "Flinders Street",
					["right terminus"] = "Sunbury",
				},
			},
		},
		["Upfield"] = {
			["title"] = "[[Upfield line]]",
			["color"] = c.Upfield,
			["left terminus"] = "Flinders Street",
			["right terminus"] = "Upfield"
		},
		["Werribee"] = {
			["title"] = "[[Werribee line]]",
			["color"] = c.Werribee,
			["text color"] = c.blk,
			["left terminus"] = "S via FS",
			["right terminus"] = "Werribee",
			["types"] = {
				["old"] = {
					["title"] = "",
					["color"] = "028430",
					["text color"] = c.wht,
					["background color"] = "",
					["left terminus"] = "F via FS",
				},
			},
		},
		["Williamstown"] = {
			["title"] = "[[Williamstown line]]",
			["color"] = c.Williamstown,
			["text color"] = c.blk,
			["left terminus"] = "S via FS",
			["right terminus"] = "Williamstown",
			["types"] = {
				["shuttle"] = {
					["title"] = "",
					["left terminus"] = "Newport",
					["note-mid"] = "Shuttle service",
				},
				["old"] = {
					["title"] = "",
					["color"] = "028430",
					["text color"] = c.wht,
					["background color"] = "",
					["left terminus"] = "F via FS",
				},
			},
		},
	},
		["aliases"] = {
			["flemington"] = "Flemington Racecourse",
			["airport"] = "Melbourne Airport",
		}	
}

return p;