Module:ShipInfobox: Difference between revisions
Content deleted Content added
m Moved to correct position |
|||
| (13 intermediate revisions by the same user not shown) | |||
Line 4:
local lang = mw.language.new('en')
-- if a variable is required, this logic hides them if variable is empty
function Infobox.
-- Rather than ParserFunctions, try passing your variables this way.
if not HF.isempty(field.Requirement) then
output = field.Value
▲ local output = mw.html.create('span')
return tostring(output)
end
return output
end
function Infobox.Factionreq( field, vars )
local output = ''
if not HF.isempty(field.Value) then
output = '[[' .. field.Value .. ']]'
return output
end
end
-- replaces {{#if:{{{topspeed|}}}|{{{topspeed|?}}} m/s|---}} logic
Line 75 ⟶ 82:
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S5 .. 'x Size 5 ' ..
lang:plural( tonumber(field.S5), 'Compartment', 'Compartments'))
matroska = true
end
if not HF.isempty(field.S6) then
if (matroska) then table.insert(output, '<br />') end
table.insert(output, field.S6 .. 'x Size 6 ' ..
lang:plural( tonumber(field.S6), 'Compartment', 'Compartments'))
matroska = true
Line 129 ⟶ 142:
end
return table.concat( output )
end
function Infobox.MaxCargo ( field, vars )
local output = ''
local number = 0
if HF.isempty(field.Cargo) then
if not HF.isempty(field.S1) then
number = number + (tonumber(field.S1) * 2)
end
if not HF.isempty(field.S2) then
number = number + (tonumber(field.S2) * 4)
end
if not HF.isempty(field.S3) then
number = number + (tonumber(field.S3) * 8)
end
if not HF.isempty(field.S4) then
number = number + (tonumber(field.S4) * 16)
end
if not HF.isempty(field.S5) then
number = number + (tonumber(field.S5) * 32)
end
if not HF.isempty(field.S6) then
number = number + (tonumber(field.S6) * 64)
end
if not HF.isempty(field.S7) then
number = number + (tonumber(field.S7) * 128)
end
if not HF.isempty(field.S8) then
number = number + (tonumber(field.S8) * 256)
end
if number == 0 then
output = "---"
else
output = tostring(number)
end
else
output = field.Cargo
end
field.Value = output
return Infobox.Quantify(field, vars)
end
| |||