Modulo:DossiersTable

Da ARK: Survival Evolved Wiki.

La documentazione per questo modulo può essere creata in Modulo:DossiersTable/man

local p = {}
function p.dossierList( f )
  local args = f:getParent().args
  local dossiers = {}

  local isSpecies = true
  local species = ''
  for _,arg in ipairs(args) do
    if isSpecies then
      species = arg
    else
      if arg == 'Book' then
        table.insert(dossiers, {d = p.dossierImage(species, 180, species), l = species})
      else
        table.insert(dossiers, {d = '[[File:'..arg..'|center|180px|link='..species..']]', l = species})
      end
    end
    isSpecies = not isSpecies
  end

  local result = ''
  for i=1, #dossiers, 2 do
    result = result .. '<tr><td style="text-align:center">' .. dossiers[i].d .. '</td>'
    if i < #dossiers then
      result = result .. '<td style="text-align:center">' .. dossiers[i+1].d .. '</td>'
    end
    result = result .. '</tr><tr><td style="text-align:center">[[' .. dossiers[i].l .. ']]</td>'
    if i < #dossiers then
      result = result .. '<td style="text-align:center">[[' .. dossiers[i+1].l .. ']]</td>'
    end
    result = result .. '</tr>'
  end

  return '<table style="margin: 1em auto;">'
  .. result
  ..'</table>'
end

function p.dossierImage(species,width,link)
  -- grab creature name from file name File:Dossier Creature.png or Dossier Creature.png or use parameter 
  local diname = string.match(species, '^File:Dossier[ _]([^.]*)%.png$')
  if diname == nil then
    diname = string.match(species, '^Dossier[ _]([^.]*)%.png$')
  end
  if diname == nil then
    diname = species
  end
  if width == nil then
    width = 4000
  end
  width = string.match(width, '%d*') -- only the digits from second parameter
  local height = math.floor(width * 2660 / 4000 + 0.5) -- scaled height according to requested width
  if link == nil then -- check for link
    link = ''
  else
    link = '|link='..link
  end

  local result = '<span style="display:inline-block;position:relative;width:'..width..'px;height:'..height..'px;">' -- container with size
  .. '<span style="position:absolute;top:0;left:0;">[[File:Dossier_Empty.png|'..width..'px|link=]]</span>' -- book as background
  .. '<span style="position:absolute;top:0;left:0;">[[File:Dossier_'..diname..'.png|'..width..'px'..link..']]</span>' -- dossier pages of the creature
  .. '</span>'
  return result
end

return p