Toggle menu
208
922
186
6.2K
Dovedale Railway Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

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

local getArgs  = require( 'Module:Arguments' ).getArgs
local infobox = require( 'Module:InfoboxNeue/Sandbox' ):new()
local getStatus = require("Module:Status").get
local showProperty = require("Module:SMWUtil").get

local p = {}

function p.infobox(frame)
    local args = getArgs(frame)

    --[[Deprecated arguments:
    image1: replaced with image (Does not support galleries)
    title1: replaced with title
    operations_information: Unused
    others: Unused
    xp_requirment: replaced with xp (bad spelling anyway)
    --]]

    --Main arguments
    local imgPath = args.image
    local title = args.title or mw.title.getCurrentTitle().text
    local captionTitle = args.caption_title
    local caption = args.caption
    local status = args.status
    local statusDescription = args.status_description

    --Info
    local stationCode = args.abbreviation or args.station_code
    local signalType = args.signal_type
    local nearestStation = args.closest_station or args.nearest_station
    local xp = args.xp

    --Operations Info
    local stationsControlled = args.stations_controlled
    local crossingsControlled = args.crossings_controlled

    --Statistics
    local home = args.home_signals_controlled
    local distant = args.distant_signals_controlled
    local points = args.points_controlled
    local shunts = args.shunt_signals_controlled

	infobox:renderImageOrGallery(imgPath)

    if status then
        local text, class = getStatus(status)
        infobox:renderIndicator( {
            data = text,
            desc = statusDescription,
            class = class
        } )
    else
    	-- render the caption indicator only if there was no status provided
    	infobox:renderIndicator( {
        	data = captionTitle,
        	desc = caption,
    	} )
	end

	infobox:renderHeader( {
		title = title,
		subtitle = 'Signal Box'
	} )

    local otherInfo = {
    	infobox:renderItem( {
    		label = "Station Code",
    		data = stationCode
    	} ),
        infobox:renderItem( {
            label = 'Signal Type',
            data = signalType
        } ),
        infobox:renderItem( {
            label = 'Nearest station',
            data = nearestStation
        } ),
        infobox:renderItem( {
            label = 'XP Requirement',
            data = showProperty(frame, mw.title.getCurrentTitle().text, "XP")
        } ),
    }
    infobox:renderSection( {
        content = table.concat(otherInfo),
        col = 3
    } )

    
    local controlled = {
        infobox:renderItem( {
            label = 'Stations controlled',
            data = stationsControlled
        } ),
        infobox:renderItem( {
            label = 'Crossings controlled',
            data = crossingsControlled
        } ),
    }
    infobox:renderSection( {
        title="Operations Information",
        content = table.concat(controlled),
        col = 2
    } )

    local stats = {
        infobox:renderItem( {
            label = 'Home signals controlled',
            data = home,
            row = true,
		    spacebetween = true
        } ),
        infobox:renderItem( {
            label = 'Distant signals controlled',
            data = distant,
            row = true,
		    spacebetween = true
        } ),
        infobox:renderItem( {
            label = 'Points controlled',
            data = points,
            row = true,
		    spacebetween = true
        } ),
        infobox:renderItem( {
            label = 'Shunt signals controlled',
            data = shunts,
            row = true,
		    spacebetween = true
        } ),
    }
    infobox:renderSection( {
        title = "Statistics",
        content = table.concat(stats),
    } )
    
	return infobox:renderInfobox(args)
end


return p
🍪 Yum Yum Yum! Cookies help us better deliver our services. By using our site, you agree to our use of cookies.