Module:ShipInfobox: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
| Line 18: | Line 18: | ||
end |
end |
||
function ShipInfobox.MainImage ( field ) |
|||
-- |
|||
end |
|||
function ShipInfobox.Factionreq( field ) |
function ShipInfobox.Factionreq( field ) |
||
| Line 29: | Line 32: | ||
end |
end |
||
end |
end |
||
-- replaces {{#if:{{{topspeed|}}}|{{{topspeed|?}}} m/s|---}} logic |
|||
function ShipInfobox.Quantify( field ) |
|||
local unit = field.Unit or '' |
|||
local value = field.Value or field.Default or '?' |
|||
if isempty(value) then |
|||
return '---' |
|||
else |
|||
return value .. ' ' .. unit |
|||
end |
|||
end |
|||
function ShipInfobox.Insurance( field ) |
|||
-- |
|||
end |
|||
function ShipInfobox.Internals( field ) |
|||
-- |
|||
end |
|||
function ShipInfobox.Hardpoints( field ) |
|||
-- |
|||
end |
|||
return ShipInfobox |
return ShipInfobox |
||
Revision as of 01:00, 23 May 2015
Documentation for this module may be created at Module:ShipInfobox/doc
local ShipInfobox = {}
-- This avoids using the {{#if:{{{factionreq|}}}||}} ParserFunction.
local function isempty(s)
local result = false
if type(s) == "nil" then
result = true
elseif type(s) == "string" then
if s == "" then
result = true
end
elseif type(s) == "table" then
if next(s) == nil then
result = true
end
end
return result
end
function ShipInfobox.MainImage ( field )
--
end
function ShipInfobox.Factionreq( field )
-- Rather than ParserFunctions, try passing your variables this way.
local text = 'Requires '.. field.Requirement ..' rank of '.. field.Rank ..' or higher'
if not isempty(field.Requirement) then
-- Use mw.html for the best HTML output.
local output = mw.html.create('span')
:addClass('factionreq'):wikitext(text)
return tostring(output)
end
end
-- replaces {{#if:{{{topspeed|}}}|{{{topspeed|?}}} m/s|---}} logic
function ShipInfobox.Quantify( field )
local unit = field.Unit or ''
local value = field.Value or field.Default or '?'
if isempty(value) then
return '---'
else
return value .. ' ' .. unit
end
end
function ShipInfobox.Insurance( field )
--
end
function ShipInfobox.Internals( field )
--
end
function ShipInfobox.Hardpoints( field )
--
end
return ShipInfobox