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:Siding/doc

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

local p = {}

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

    --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

    local trainSpawners = args.train_spawners
    local tracks = args.tracks
    local closestStation = args.closest_station
    local signalBox = args.signal_box
    
    -- meta properties
    local use_subobject = args.use_subobject
    local smwIdentifier = frame:preprocess("{{FULLPAGENAME}}")

    if use_subobject == "true" then
        smwIdentifier = smwIdentifier .. "#" .. title
        createSubobject(frame, title, {
        	"Title=" .. (title or ""),
            "Image=" .. (imgPath or ""),
            "Train Spawners=" .. (trainSpawners or ""),
            "Tracks=" .. (tracks or ""),
            "Closest Station=" .. (closestStation or ""),
            "Signal Box=" .. (signalBox or "")
            "Status=" .. (status or ""),
            "Status Description=" .. (statusDescription or "")
        })
    end

	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 = 'Siding'
	} )

    local labels = {
        infobox:renderItem( {
            label = 'Train Spawners',
            data = trainSpawners
        } ),
        infobox:renderItem( {
            label = 'Tracks',
            data = tracks
        } ),
        infobox:renderItem( {
            label = 'Closest Station',
            data = closestStation
        } ),
        infobox:renderItem( {
            label = 'Signal Box',
            data = signalBox
        } ),
    }
    infobox:renderSection( {
        content = table.concat(labels),
        col = 2
    } )
    
	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.