This documentation is transcluded from Module:Transit/doc. Changes can be proposed in the talk page.
Module:Transit is shared across the Star Citizen Wikis.
This module is shared across the Star Citizen Wikis. Any changes should also be relayed to the GitHub repository.
This module is unused.
This module is neither invoked by a template nor required/loaded by another module. If this is in error, make sure to add
{{Documentation}}
/{{No documentation}}
to the calling template's or parent's module documentation.Function list |
---|
L 13 — t L 23 — Transit.main L 60 — Transit.fromTemplate |
Used to show transit line in Star Citizen universe as a badge. The colors are defined in the data.json.
local Transit = {}
local i18n = require( 'Module:i18n' ):new()
local data = mw.loadJsonData( 'Module:Transit/data.json' )
local mArguments
--- Wrapper function for Module:i18n.translate
---
--- @param key string The translation key
--- @return string|nil
local function t( key )
return i18n:translate( key )
end
--- Return a badge in wikitext using data defined in data.json
---
--- @param location string
--- @param name string
--- @param frame table
--- @return string
function Transit.main( location, name, frame )
if not location and not name then
return string.format( '<span class="error">%s</span>', t( 'message_error_no_text' ) )
end
local bg = '#000'
local color = '#fff'
for locationName, locationData in pairs( data.locations ) do
if locationName == location then
mw.logObject( locationData )
for lineName, lineData in pairs( locationData.lines ) do
if lineName == name then
bg = lineData.bg
color = lineData.color
break
end
end
break
end
end
frame = frame or mw.getCurrentFrame()
return frame:expandTemplate{
title = 'Badge',
args = {
name,
bg = bg,
color = color
}
}
end
--- Helper function for templates invoking the module
---
--- @param frame table
--- @return string
function Transit.fromTemplate( frame )
mArguments = require( 'Module:Arguments' )
local args = mArguments.getArgs( frame )
return Transit.main( args[1], args[2], frame )
end
return Transit