Module:ShipInfobox: Difference between revisions
Content deleted Content added
mNo edit summary |
mNo edit summary |
||
Line 5:
-- This avoids using the {{#if:{{{factionreq|}}}||}} ParserFunction.
function Infobox.Factionreq( field, vars )
-- Rather than ParserFunctions, try passing your variables this way.
local text = 'Requires [['.. field.Requirement ..']] rank of '.. field.Rank ..' or higher'
if not HF.isempty(field.Requirement) then
-- Use mw.html for the best HTML output.
local output = mw.html.create('span')
Line 36 ⟶ 20:
local unit = field.Unit or ''
local value = field.Value or field.Default or '?'
if HF.isempty(value) then
return '---'
else
Line 45 ⟶ 29:
-- fixes numbers with commas, e.g: 4,323
function Infobox.FormatCost( field, vars )
if HF.isempty(field.Value) then
return '---'
else
field.
return Infobox.Quantify(field, vars)
end
Line 56 ⟶ 40:
-- replaces {{#if:{{{cost|}}}|{{formatnum:{{#expr:trunc({{formatnum:{{{cost|}}}|R}}*0.05)}}}} CR|}}
local insurance = field.Cost:gsub(',','')
if not HF.isempty(insurance) then
return FormatNum.commavalue(math.floor(tonumber(insurance) * 0.05)) .. ' CR'
else return ''
Line 65 ⟶ 49:
local matroska = nil
local output = {}
if not HF.isempty(field.S1) then
table.insert(output, field.S1 .. 'x Size 1 ' ..
lang:plural( tonumber(field.S1), 'Compartment', 'Compartments'))
matroska = true
end
if not HF.isempty(field.S2) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S2 .. 'x Size 2 ' ..
Line 76 ⟶ 60:
matroska = true
end
if not HF.isempty(field.S3) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S3 .. 'x Size 3 ' ..
Line 82 ⟶ 66:
matroska = true
end
if not HF.isempty(field.S4) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S4 .. 'x Size 4 ' ..
Line 88 ⟶ 72:
matroska = true
end
if not HF.isempty(field.S5) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S5 .. 'x Size 5 ' ..
Line 94 ⟶ 78:
matroska = true
end
if not HF.isempty(field.S7) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S7 .. 'x Size 7 ' ..
Line 100 ⟶ 84:
matroska = true
end
if not HF.isempty(field.S8) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S8 .. 'x Size 8 ' ..
Line 106 ⟶ 90:
matroska = true
end
if not HF.isempty(field.Reserved) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.Reserved)
Line 116 ⟶ 100:
local matroska = nil
local output = {}
if not HF.isempty(field.Utility) then
table.insert(output, field.Utility .. 'x Utility ' ..
lang:plural( tonumber(field.Utility), 'Mount', 'Mounts'))
matroska = true
end
if not HF.isempty(field.S) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S .. 'x Small ' ..
Line 127 ⟶ 111:
matroska = true
end
if not HF.isempty(field.M) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.M .. 'x Medium ' ..
Line 133 ⟶ 117:
matroska = true
end
if not HF.isempty(field.L) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.L .. 'x Large ' ..
Line 139 ⟶ 123:
matroska = true
end
if not HF.isempty(field.H) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.H .. 'x Huge ' ..
| |||