Documentation for this module may be created at Module:Data/Starships/doc
local p = {}
local utils = require("Module:TemplateUtils")
local baseUtils = require("Module:Data")
local techrow = [[|-
|%s
|%s
|%s
]]
local wonderrow = [[|-
|%s
|%s
|%s
]]
local battlecardrow = [[|-
|%s
|%s
|%s
|%s
]]
local wonderpage = [=[<div class="container-with-margins" style="float:right; max-width:402px; clear:right;">
{| class="civbetable" style="margin:0;"
|+<big><big>'''%s'''</big></big>
|colspan="2" align="center"|%s<br/>
Wonder in ''[[Sid Meier's Starships]]''
|-
!colspan="2" align="center"|Description
|-
|colspan="2"| %s
|}</div>
{{BackArrow|List of wonders in Starships|Back to the list of wonders}}{{#if:{{NAMESPACE}} | |[[Category:Wonders (Starships)]]}}]=]
function p.GetWonderRow(frame, articlename)
local PAGENAME = articlename or frame.args[1]
local name = string.gsub(PAGENAME, " %(.*","")
local data = mw.loadData("Module:Data/Starships/Wonders")
local wonder = data[name]
local missing = "([[Module:Data/Starships/Wonders|Information missing]])"
return utils.PreProcess(frame,string.format(wonderrow,
"[[File:"..PAGENAME.." (Starships).png|120px]]",
"[["..name.." (Starships)|"..name.."]]",
wonder.description or missing))
end
function p.GetWonderPage(frame, articlename)
local PAGENAME = articlename or mw.title.getCurrentTitle().text
local name = string.gsub(PAGENAME, " %(.*","")
local data = mw.loadData("Module:Data/Starships/Wonders")
local wonder = data[name]
local missing = "([[Module:Data/Starships/Wonders|Information missing]])"
if wonder == nil then
return "''Wonder infobox data not found. Check the page name or add the data to [[Module:Data/Starships/Wonders]].''[[Category:Wonders (Starships)]]"
end
return utils.PreProcess(frame,string.format(wonderpage,
name,
"[[File:"..PAGENAME..".png|180px]]",
wonder.description or missing))
end
local techpage = [=[<div class="container-with-margins" style="float:right; max-width:402px; clear:right;">
{| class="civbetable" style="margin:0;"
|+<big><big>'''%s'''</big></big>
|colspan="2" align="center"|%s<br/>
Technology in ''[[Sid Meier's Starships]]''
|-
!colspan="2" align="center"|Description
|-
|colspan="2"| %s
|}</div>
{{BackArrow|List of technologies in Starships|Back to the list of technologies}}{{#if:{{NAMESPACE}} | |[[Category:Technologies (Starships)]]}}]=]
function p.GetTechRow(frame, articlename)
local PAGENAME = articlename or frame.args[1]
local name = string.gsub(PAGENAME, " %(.*","")
local data = mw.loadData("Module:Data/Starships/Techs")
local tech = data[name]
local missing = "([[Module:Data/Starships/Techs|Information missing]])"
return utils.PreProcess(frame,string.format(techrow,
"[[File:"..PAGENAME.." (Starships).png|120px]]",
"[["..name.." (Starships)|"..name.."]]",
tech.description or missing))
end
function p.GetTechPage(frame, articlename)
local PAGENAME = articlename or mw.title.getCurrentTitle().text
local name = string.gsub(PAGENAME, " %(.*","")
local data = mw.loadData("Module:Data/Starships/Techs")
local tech = data[name]
local missing = "([[Module:Data/Starships/Techs|Information missing]])"
if tech == nil then
return "''Tech infobox data not found. Check the page name or add the data to [[Module:Data/Starships/Techs]].''[[Category:Technologies (Starships)]]"
end
return utils.PreProcess(frame,string.format(techpage,
name,
"[[File:"..PAGENAME..".png|120px]]",
tech.description or missing))
end
local battlecardpage = [=[<div class="container-with-margins" style="float:right; max-width:402px; clear:right;">
{| class="civbetable" style="margin:0;"
|+<big><big>'''%s'''</big></big>
|colspan="2" align="center"|%s<br/>
Battle Card in ''[[Sid Meier's Starships]]''
|-
! Rarity
| %s
|-
!colspan="2" align="center"|Description
|-
|colspan="2"| %s
|}</div>
{{BackArrow|List of Battle Cards in Starships|Back to the list of Battle Cards}}{{#if:{{NAMESPACE}} | |[[Category:Battle Cards (Starships)]]}}]=]
function p.GetBattleCardRow(frame, articlename)
local PAGENAME = articlename or frame.args[1]
local name = string.gsub(PAGENAME, " %(.*","")
local data = mw.loadData("Module:Data/Starships/Battle Cards")
local bc = data[name]
local missing = "([[Module:Data/Starships/Battle Cards|Information missing]])"
return utils.PreProcess(frame,string.format(battlecardrow,
"[[File:"..PAGENAME:gsub("/","-").." (Starships).png|60px]]",
"[["..name.." (Starships)|"..name.."]]",
bc.rarity or missing,
bc.description or missing))
end
function p.GetBattleCardPage(frame, articlename)
local PAGENAME = articlename or mw.title.getCurrentTitle().text
local name = string.gsub(PAGENAME, " %(.*","")
local data = mw.loadData("Module:Data/Starships/Battle Cards")
local bc = data[name]
local missing = "([[Module:Data/Starships/Battle Cards|Information missing]])"
if bc == nil then
return "''Battle Card infobox data not found. Check the page name or add the data to [[Module:Data/Starships/Battle Cards]].''[[Category:Battle Cards (Starships)]]"
end
return utils.PreProcess(frame,string.format(battlecardpage,
name,
"[[File:"..PAGENAME:gsub("/","-")..".png|120px]]",
bc.rarity or missing,
bc.description or missing))
end
local steamachievementbox = [=[{| class="steam-achievement-container"
!class="steam-achievement-image-cell" |[[File:Steam achievement %s (Starships).jpg|64px|%s]]
!class="steam-achievement-text-cell"|<div class="steam-achievement-text-cell-inner-container"><span class="steam-achievement-name">%s</span><br/><div class="steam-achievement-description">%s
:%s</div></div>
|}[[Category:Steam achievements (Starships)]]]=]
local function isEmpty(param)
return param == nil or param == ''
end
function p.GetSteamAchievement(frame, articlename)
local PAGENAME = articlename or frame.args[1]
local name = string.gsub(PAGENAME, " %(.*","")
local data = mw.loadData("Module:Data/Starships/Steam_achievements")[name]
local missing = "<small>(Is this a reference to something in popular culture? Please [[Module:Data/Starships/Steam achievements|add the information here]]!)</small>"
if data == nil then
return "''Achievement infobox data not found for \""..name.."\". Check the parameter or add the data to [[Module:Data/Starships/Steam achievements]].''"
end
return utils.PreProcess(frame,string.format(steamachievementbox,
name, name, name,
data.condition,
not isEmpty(data.reference) and data.reference or missing))
end
return p