Modulo:RequiredCraftingStations

Da ARK Wiki.
Jump to navigation Jump to search

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

local p = {}
function p.neededstations( f )
  local args = f:getParent().args
  local stations = {["Fuoco da campo"] = false, ["Mortaio e pestello"] = false, ["Fucina di raffinazione"] = false, ["Conservatore"] = false, ["Bancone"] = false, ["Assemblatore"] = false}
  local dependencies = {
    ["Fuoco da campo"] = {
      "Carbonella",
      "Carne cotta",
      "Carne cotta pregiata",
      "Polvere da sparo"
    },
    ["Mortaio e pestello"] = {
      "Polvere pirica",
      "Narcotico",
      "Polvere da sparo",
      "Stimolante",
      "Pasta cementizia",
      "Repellente",
      "Polimero",
      "Argilla",
      "Propellente"
    },
    ["Fucina di raffinazione"] = {
      "Lingotto di metallo",
      "Gasolio",
      "Elettronica",
      "Mattoni",
      "Vetro",
      "Lingotto di ferro",
      "Lingotto d'acciaio"
    },
    ["Conservatore"] = {
      "Carne essiccata cotta",
      "Carne essiccata pregiata"
    },
    ["Bancone"] = {
      "Dardo sedativo"
    },
    ["Assemblatore"] = {
      "Elettronica",
      "Polimero"
    },
    ["Banco chimico"] = {
      "Substrato assorbente"
    },
  --Primitive Plus
    ["Apiario"] = {
      "Miele",
      "Cera d'api"
    },
    ["Calderone"] = {
      "Lievito naturale",
      "Latte di anacardi"
    },
    ["Betoniera"] = {
      "Cemento fresco"
    },
    ["Banco di cottura"] = {
      "Impasto fresco"
    },
    ["Macina"] = {
      "Argilla (Primitive+)",
      "Sacco di farina",
      "Sale"
    },
    ["Stazione del legname"] = {
      "Assi di legno"
    },
    ["Fuoco da campo conservante"] = {
      "Orzo essiccato",
      "Bustine di tè essiccate",
      "Grano essiccato"
    },
    ["Pressa per zucchero"] = {
      "Secchio di succo di zucchero fresco"
    },
    ["Telaio per cuoio"] = {
      "Cuoio"
    }
  }

  -- check if item itself needs a station to be crafted in. if yes, set to true
  if args.craftedin ~= nil and stations[args.craftedin] ~= nil then
    stations[args.craftedin] = true
  end
  -- get iconsize
  local iconsize = '20px'
  if args.iconsize ~= nil then
    iconsize = args.iconsize
  end

  -- test all given resources and set station to true if needed and station is not already on true
  for _,res in ipairs(args) do
    if res ~= '' then
      for station,_ in pairs(dependencies) do
        if not stations[station] and p.inTable(dependencies[station], res) then
          stations[station] = true
        end
      end
    end
  end

  local returnTable = {}
  for station, needed in pairs(stations) do
    if needed then
      table.insert(returnTable,'[[File:'..station..'.png|'..iconsize..']] [['..station..']]')
    end
  end

  return table.concat(returnTable,'<br/>')
end

function p.inTable(tbl, item)
  for _, value in pairs(tbl) do
    if string.lower(value) == string.lower(item) then return true end
  end
  return false
end

return p