m (1 revision imported) |
m (1 revision imported) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
local Nation = {} | local Nation = {} | ||
local infobox = require( 'Module:Infobox' ):new() | local infobox = require( 'Module:Infobox' ):new({ | ||
class = 'nation' | |||
}) | |||
local hatnote = require( 'Module:Hatnote' )._hatnote | local hatnote = require( 'Module:Hatnote' )._hatnote | ||
local data = mw.loadJsonData( 'Module:System/data.json' ) | local data = mw.loadJsonData( 'Module:System/data.json' ) | ||
Line 58: | Line 60: | ||
-- Render Header Box -- | -- Render Header Box -- | ||
if parentArgs.player then | |||
infobox:renderIndicator( { | |||
data = 'Player', | |||
desc = parentArgs.player, | |||
class = 'player' | |||
} ) | |||
else | |||
infobox:renderIndicator( { | |||
data = 'NPC', | |||
class = 'npc' | |||
} ) | |||
end | |||
infobox:renderHeader( { | infobox:renderHeader( { |
Latest revision as of 16:42, 31 March 2024
This documentation is transcluded from Module:Infobox Nation/doc. Changes can be proposed in the talk page.
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 8 — systemLink L 15 — speciesLink L 21 — techLink L 27 — Nation.main |
local Nation = {} local infobox = require( 'Module:Infobox' ):new({ class = 'nation' }) local hatnote = require( 'Module:Hatnote' )._hatnote local data = mw.loadJsonData( 'Module:System/data.json' ) function systemLink(systemid, systemname) local urlName = string.gsub(systemname, "%s+", "_") systemid = string.gsub(systemid, "%s+", "") local link = "<span class='plainlinks'>[" .. mw.site.server .. "/index.php?action=edit&redlink=1&preload=Template:Systems/Preload&preloadparams%5B%5D=" .. systemid .. "&title=" .. urlName .. " " .. systemname .. "]</span>" return link end function speciesLink(speciesname) local urlName = string.gsub(speciesname, "%s+", "_") local link = "<span class='plainlinks'>[" .. mw.site.server .. "/index.php?action=edit&redlink=1&preload=Template:Species/Preload&title=" .. urlName .. " " .. speciesname .. "]</span>" return link end function techLink(techname) local urlName = string.gsub(techname, "%s+", "_") local link = "<span class='plainlinks'>[" .. mw.site.server .. "/index.php?action=edit&redlink=1&preload=Template:Technology/Preload&title=" .. urlName .. " " .. techname .. "]</span>" return link end function Nation.main(frame) local parentFrame = frame:getParent() local parentArgs = parentFrame.args if parentArgs.name == nil then return hatnote( mw.ustring.format( 'A required field (%s) is missing!', 'name' ), { icon = 'WikimediaUI-Error.svg', extraclasses = 'error' } ) end local basicsTable = {} local systemsTable = {} local speciesTable = {} local techTable = {} -- Check if required fields are present (name) -- if parentArgs.image == nil then infobox:renderImage( 'Aegis50.svg' ) else infobox:renderImage( parentArgs.image ) end -- Check if aka exists, if so, prepend label -- local aka = nil if parentArgs.aka ~= nil then aka = "<span class='aka'>aka:</span> " .. parentArgs.aka end -- Render Header Box -- if parentArgs.player then infobox:renderIndicator( { data = 'Player', desc = parentArgs.player, class = 'player' } ) else infobox:renderIndicator( { data = 'NPC', class = 'npc' } ) end infobox:renderHeader( { title = parentArgs.name, subtitle = aka, } ) -- Render Basics Table (type, capital) -- local fieldType = 'Not specified' if parentArgs['type'] == nil or parentArgs['type'] == ' ' or parentArgs['type'] == '' then fieldType = 'Not specified' else fieldType = parentArgs.type end local fieldCapital = 'Not specified' if parentArgs['capital'] == nil or parentArgs['capital'] == ' ' or parentArgs['capital'] == '' then fieldCapital = 'Not specified' else local capitalId = tonumber( parentArgs.capital ) if capitalId == nil then fieldCapital = 'Invalid system (' .. parentArgs.capital .. ')' else capitalId = capitalId + 1 if data[capitalId] then --local urlName = string.gsub(data[capitalId].name, "%s+", "_") --fieldCapital = "<span class='plainlinks'>[" .. mw.site.server .. "/index.php?action=edit&redlink=1&preload=Template:Systems/Preload&preloadparams%5B%5D=" .. parentArgs.capital .. "&title=" .. urlName .. " " .. data[capitalId].name .. "]</span>" fieldCapital = systemLink(parentArgs.capital, data[capitalId].name) else fieldCapital = 'Invalid system (' .. parentArgs.capital .. ')' end end end basicsTable = { infobox:renderItem( { label = 'Govenment Type', data = fieldType } ), infobox:renderItem( { label = 'Capital System', data = fieldCapital } ) } infobox:renderSection( { content = table.concat( basicsTable ), col = 2 } ) if parentArgs['systems'] ~= nil and parentArgs['systems'] ~= ' ' and parentArgs['systems'] ~= '' then local systemsList = mw.text.split(parentArgs.systems, ',') for _, v in pairs( systemsList ) do local sysName = 'Invalid system (' .. v .. ')' local sysId = tonumber( v ) if sysId == nil then sysName = 'Invalid system (' .. v .. ')' else sysId = sysId + 1 if data[sysId] then sysName = systemLink(v, data[sysId].name) else sysName = 'Invalid system (' .. sysId .. ')' end end local systemsItem = infobox:renderItem( { data = sysName }) table.insert(systemsTable, systemsItem) end infobox:renderSection( { title = 'Claimed Systems', content = table.concat( systemsTable ), col = 3, class = 'smalltitle' }) end if parentArgs['species'] ~= nil and parentArgs['species'] ~= ' ' and parentArgs['species'] ~= '' then local speciesList = mw.text.split(parentArgs.species, ',') for _, v in pairs( speciesList ) do local speciesItem = infobox:renderItem( { data = speciesLink(v) }) table.insert(speciesTable, speciesItem) end infobox:renderSection( { title = 'Predomiment Species', content = table.concat( speciesTable ), col = 3, class = 'smalltitle' }) end if parentArgs['tech'] ~= nil and parentArgs['tech'] ~= ' ' and parentArgs['tech'] ~= '' then local techList = mw.text.split(parentArgs.tech, ',') for _, v in pairs( techList ) do local techItem = infobox:renderItem( { data = techLink(v) }) table.insert(techTable, techItem) end infobox:renderSection( { title = 'Signature Technology', content = table.concat( techTable ), col = 3, class = 'smalltitle' }) end return infobox:renderInfobox( nil, parentArgs.name) end return Nation