Module:ShipInfobox: Difference between revisions

Content deleted Content added
m Added size 6
m Undo revision 44853 by SpyTec (talk)
 
(12 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
-- This avoids using the {{#if:{{{factionreq|}}}||}} ParserFunction.
function Infobox.FactionreqRequired( field, vars )
-- Rather than ParserFunctions, try passing your variables this way.
local output = mw.html.create('span')▼
local text = 'Requires [['.. field.Requirement ..']] rank of '.. field.Rank ..' or higher'
if not HF.isempty(field.Requirement) then
output = field.Value
-- Use mw.html for the best HTML output.
▲ local output = mw.html.create('span')
:addClass('factionreq'):wikitext(text)
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 135 ⟶ 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