Content deleted Content added
Alistair3149 (talk | contribs) No edit summary |
Alistair3149 (talk | contribs) No edit summary |
||
Line 20: | Line 20: | ||
--- @param frame table |
--- @param frame table |
||
--- @return string |
--- @return string |
||
function Transit.fromTemplate( |
function Transit.fromTemplate( frame ) |
||
mArguments = require( 'Module:Arguments' ) |
mArguments = require( 'Module:Arguments' ) |
||
local args = mArguments.getArgs( frame ) |
local args = mArguments.getArgs( frame ) |
Revision as of 22:50, 17 October 2024
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 |
---|
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
--- 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 )
local location = args[1]
local name = args[2]
if not location and not name then
return mw.ustring.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
return frame:expandTemplate{
title = 'Badge',
args = {
name,
bg = bg,
color = color
}
}
end
return Transit