Jump to content

Module:ShipInfobox: Difference between revisions

From Elite Dangerous Wiki
Content deleted Content added
mNo edit summary
No edit summary
Line 1: Line 1:
local ShipInfobox = {}
local ShipInfobox = {}


-- This avoids using the {{#if:{{{factionreq|}}}||}} ParserFunction.
⚫
function ShipInfobox.Factionreq( field, vars )
local output = ""
local function isempty(s)
local result = false
output = output .. '<span class="factionreq">' .. field.Value .. '</span>'
if type(s) == "nil" then
⚫
return output
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.Factionreq( field )
local text = 'Requires '.. field.Requirement ..' rank of '.. file.Rank ..' or higher'
if not isempty(field.Requirement) then
local output = mw.html.create('span')
:addClass('factionreq'):wikitext(text)
⚫
return tostring(output)
end
end
end



Revision as of 23:43, 22 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.Factionreq( field )
    local text = 'Requires '.. field.Requirement ..' rank of '.. file.Rank ..' or higher'
    if not isempty(field.Requirement) then
        local output = mw.html.create('span')
        :addClass('factionreq'):wikitext(text)
        return tostring(output)
    end
end  

return ShipInfobox