Module:Infobox/sandbox: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(Better account for fully whitespace args in row and vrow)
mNo edit summary
 
(44 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local util = require("Module:Util")
local parsing = require("Module:Infobox/parsing/sandbox")
local p = {}
local p = {}


function p.row(frame)
function p.base_tab(frame) -- no prefix for args. Used for vanilla tab or if no tabs
   local args = frame.args
  local args = frame:getParent().args
   if not p.clean_arg(args[2]) then
  local ret = {}
     return
   local sa = frame:expandTemplate{title = "Space age"} .. " "
 
  if not util._empty_arg(args["recipe"]) then
    ret[#ret+1] = p._vrow(frame, {"Recipe",    args["recipe"], parsing._crafting(frame, args["recipe"])})
    ret[#ret+1] = p._vrow(frame, {"Total raw", args["recipe"], parsing._crafting_raw(frame, util._arg_or(args["total-raw"], args["recipe"]))})
  end
 
  if not util._empty_arg(args["cost"]) then
    local cost = parsing._item(frame, args["cost"]) .. ((not util._empty_arg(args["cost-multiplier"])) and "✖ <big>" .. args["cost-multiplier"] .. "</big>" or "")
    ret[#ret+1] = p._vrow(frame, {"Cost", args["cost"], cost})
  end
   if not util._empty_arg(args["technology-trigger"]) then
    ret[#ret+1] = p._vrow(frame, {"Researched by", args["technology-trigger"], parsing._technology_trigger(frame, args["technology-trigger"])})
  end
 
  ret[#ret+1] = p._extra    (frame,                          args["extra1"])
 
  if not util._empty_arg(args["map-color"]) then
     local color = frame:expandTemplate{title = 'Color', args = {args["map-color"]}}
    ret[#ret+1] = p._row(frame, {"Map color", args["map-color"], color})
   end
   end


   local label = frame:expandTemplate{title = 'Translation', args = {args[1]}}
   ret[#ret+1] = p._row_simple(frame, "Map icon",              args["map-icon"])
  ret[#ret+1] = p._row_simple(frame, "Added in",              args["added-in"])
  ret[#ret+1] = p._row_simple(frame, "Walking speed",        args["walking-speed"])
  ret[#ret+1] = p._row_simple(frame, "Storage size",          args["storage-size"])
  ret[#ret+1] = p._row_simple(frame, "Fluid storage volume",  args["fluid-storage-volume"])


   return string.format(
   if not util._empty_arg(args["expected-resources"]) then
    local label = p._translate(frame, "Expected resources")
    ret[#ret+1] = string.format(
[[<tr class="border-top">
[[<tr class="border-top">
<td>
<td>
%s
%s
</td>
</td>
<td>
<td style="width: 70%%;">
%s
%s
</td>
</td>
</tr>]],
</tr>]], label, args["expected-resources"])
     label,
  end
     args[3] or args[2])
 
  ret[#ret+1] = p._row_simple(frame, "Health",                args["health"])
  ret[#ret+1] = p._row_unit  (frame, "Restores",              args["restores"],            "health")
  ret[#ret+1] = p._row_simple(frame, "Resistances",          args["resistance"])
  ret[#ret+1] = p._row_unit  (frame, "Lifespan",              args["lifespan"],            "seconds")
  ret[#ret+1] = p._row_simple(frame, "Inventory size bonus",  args["inventory-size-bonus"])
  ret[#ret+1] = p._row_simple(frame, "Equipment grid size",  args["grid-size"])
  ret[#ret+1] = p._row_simple(frame, "Stack size",            args["stack-size"])
  ret[#ret+1] = p._row_simple(frame, "Rocket capacity",      args["rocket-capacity"], sa)
  ret[#ret+1] = p._row_simple(frame, "Range",                args["range"])
  ret[#ret+1] = p._row_simple(frame, "Shooting speed",        args["shooting-speed"])
  ret[#ret+1] = p._row_simple(frame, "Damage",                args["damage"])
  ret[#ret+1] = p._row_simple(frame, "Damage bonus",          args["damage-bonus"])
  ret[#ret+1] = p._row_simple(frame, "Cluster size",          args["cluster-size"])
  ret[#ret+1] = p._row_simple(frame, "Area of effect size",  args["area-of-effect-size"])
  ret[#ret+1] = p._row_simple(frame, "Durability",            args["durability"])
  ret[#ret+1] = p._row_simple(frame, "Magazine size",        args["magazine-size"])
  ret[#ret+1] = p._row_item  (frame, "Ammunition",            args["ammunition"])
  ret[#ret+1] = p._vrow_item (frame, "Used as ammunition by", args["used-as-ammo-by"])
  ret[#ret+1] = p._row_simple(frame, "Efficiency",            args["efficiency"])
  ret[#ret+1] = p._row_simple(frame, "Dimensions",            args["dimensions"])
  ret[#ret+1] = p._row_type  (frame, "Energy consumption",    args["energy"])
  ret[#ret+1] = p._row_type  (frame, "Drain",                args["drain"])
  ret[#ret+1] = p._row_type  (frame, "Robot recharge rate",  args["robot-recharge-rate"])
  ret[#ret+1] = p._row_type  (frame, "Internal buffer recharge rate", args["internal-buffer-recharge-rate"])
  ret[#ret+1] = p._vrow_item (frame, "Placed in",            args["equipped-in"])
  ret[#ret+1] = p._row_simple(frame, "Robot limit",          args["robot-limit"])
  ret[#ret+1] = p._row_simple(frame, "Repair speed",          args["repair-speed"])
  ret[#ret+1] = p._row_simple(frame, "Charging stations",    args["charging-stations"])
  ret[#ret+1] = p._row_simple(frame, "Rotation speed",        args["rotation-speed"])
  ret[#ret+1] = p._row_simple(frame, "Belt speed",            args["belt-speed"])
  ret[#ret+1] = p._row_simple(frame, "Collection area",      args["asteroid-collection-area"])
  ret[#ret+1] = p._row_simple(frame, "Collection arm speed",  args["asteroid-collection-arm-speed"])
  ret[#ret+1] = p._row_simple(frame, "Collection arm count",  args["asteroid-collection-arm-count"])
  ret[#ret+1] = p._row_simple(frame, "Movement bonus",        args["movement-bonus"])
  ret[#ret+1] = p._row_type  (frame, "Energy capacity",      args["energy-capacity"])
  ret[#ret+1] = p._row_simple(frame, "Power input",          args["power-input"])
  ret[#ret+1] = p._row_simple(frame, "Power output",          args["power-output"])
  ret[#ret+1] = p._row_simple(frame, "Heat output",          args["heat-output"])
  ret[#ret+1] = p._row_simple(frame, "Maximum temperature",  args["maximum-temperature"])
  ret[#ret+1] = p._row_simple(frame, "Fluid consumption",    args["fluid-consumption"])
  ret[#ret+1] = p._row_simple(frame, "Shield hitpoints",      args["shield"])
  ret[#ret+1] = p._row_type  (frame, "Energy per hitpoint",  args["energy-per-hitpoint"])
  ret[#ret+1] = p._row_simple(frame, "Maximum recharge speed",args["maximum-recharge-speed"])
  ret[#ret+1] = p._row_simple(frame, "Crafting speed",        args["crafting-speed"])
  ret[#ret+1] = p._row_simple(frame, "Pumping speed",        args["pumping-speed"])
  ret[#ret+1] = p._row_simple(frame, "Mining time",          args["mining-time"])
  ret[#ret+1] = p._row_simple(frame, "Speed",                args["speed"])
  ret[#ret+1] = p._row_simple(frame, "Productivity",          args["productivity"])
  ret[#ret+1] = p._row_simple(frame, "Quality",              args["quality"], sa)
  ret[#ret+1] = p._row_simple(frame, "Mining speed",          args["mining-speed"])
  ret[#ret+1] = p._row_unit  (frame, "Mining area",          args["mining-area"],          "tiles")
  ret[#ret+1] = p._row_simple(frame, "Resource drain",        args["resource-drain"])
  ret[#ret+1] = p._row_simple(frame, "Science pack drain",    args["science-pack-drain"])
  ret[#ret+1] = p._row_simple(frame, "Base productivity",     args["base-productivity"])
  ret[#ret+1] = p._row_type  (frame, "Fuel value",            args["fuel-value"])
  ret[#ret+1] = p._row_simple(frame, "Vehicle acceleration",  args["vehicle-acceleration"])
  ret[#ret+1] = p._row_simple(frame, "Vehicle top speed",    args["vehicle-top-speed"])
  ret[#ret+1] = p._row_unit  (frame, "Supply area",          args["supply-area"],          "tiles")
  ret[#ret+1] = p._row_unit  (frame, "Wire reach",            args["wire-reach"],            "tiles")
  ret[#ret+1] = p._row_unit  (frame, "Construction area",    args["construction-area"],    "tiles")
  ret[#ret+1] = p._row_simple(frame, "Pollution",            args["pollution"])
  ret[#ret+1] = p._row_item  (frame, "Buildable only on",    args["buildable-on"], sa)
  ret[#ret+1] = p._row_item  (frame, "Crafted only on",      args["crafted-on"], sa)
  ret[#ret+1] = p._row_unit  (frame, "Spoil time",            args["spoil-time"],            "minutes", sa)
  ret[#ret+1] = p._row_item  (frame, "Spoil result",          args["spoil-result"], sa)
  ret[#ret+1] = p._row_simple(frame, "Weight",                args["vehicle-weight"])
  ret[#ret+1] = p._row_unit  (frame, "Module slots",          args["modules"],              "slots")
 
  if not util._empty_arg(args["prototype-type"]) then
    local prototype_type = frame:expandTemplate{title = 'Prototype page', args = {args["prototype-type"]}}
    ret[#ret+1] = p._row(frame, {"Prototype type", args["prototype-type"], prototype_type})
  end
  ret[#ret+1] = p._row_simple(frame, "Internal name",        args["internal-name"])
 
  ret[#ret+1] = p._vrow_item (frame, "Accepted equipment",    args["equipment"])
  ret[#ret+1] = p._vrow_tech (frame, "Required technologies", args["required-technologies"])
  ret[#ret+1] = p._vrow_tech (frame, "Allows",                args["allows"])
  ret[#ret+1] = p._vrow_item (frame, "Effects",              args["effects"])
  ret[#ret+1] = p._vrow_tech (frame, "Boosting technologies", args["boosting-technologies"])
  ret[#ret+1] = p._vrow_item (frame, "Produced by",          args["producers"])
  ret[#ret+1] = p._vrow_item (frame, "Consumed by",          args["consumers"])
  ret[#ret+1] = p._vrow_item (frame, "Valid fuel",            args["valid-fuel"])
  ret[#ret+1] = p._vrow_item (frame, "Used as fuel by",       args["used-as-fuel-by"])
  ret[#ret+1] = p._vrow_item (frame, "Recycling results",     args["recycling-results"], sa)
  ret[#ret+1] = p._extra    (frame,                          args["extra2"])
 
  return table.concat(ret)
end
end


function p.vrow(frame)
function p.space_age_tab(frame) -- space-age prefix for some args. Used for space age mod tab
   local args = frame.args
  local args = frame:getParent().args
  local ret = {}
  local sa = frame:expandTemplate{title = "Space age"} .. " "
 
  local recipe = util._arg_or(args["space-age-recipe"], args["recipe"])
   if not util._empty_arg(recipe) then
    ret[#ret+1] = p._vrow(frame, {"Recipe",    recipe, parsing._crafting(frame, recipe)})
    local vanilla_total_raw = util._arg_or(args["total-raw"], args["recipe"])
    ret[#ret+1] = p._vrow(frame, {"Total raw", recipe, parsing._crafting_raw(frame, util._arg_or(args["space-age-total-raw"],  util._arg_or(args["space-age-recipe"], vanilla_total_raw)))})
  end


   local label = frame:expandTemplate{title = 'Translation', args = {args[1]}}
   local cost_arg = util._arg_or(args["space-age-cost"], args["cost"])
   local content = ""
   local tech_trigger_arg = util._arg_or(args["space-age-technology-trigger"], args["technology-trigger"])
   if p.clean_arg(args[2]) then
   if not util._empty_arg(cost_arg) and cost_arg ~= "none" then
     content = args[3] or args[2]
     local cost_multiplier_arg = util._arg_or(args["space-age-cost-multiplier"], args["cost-multiplier"])
  elseif p.clean_arg(args[4]) then -- We might want to remove this since it is only used to display "None required" for field required-technologies, but it's kind of obvious no technologies are required if it's not in the infobox already
    local cost = parsing._item(frame, cost_arg) .. ((not util._empty_arg(cost_multiplier_arg)) and "✖ <big>" .. cost_multiplier_arg .. "</big>" or "")
     content = "<i>" .. args[4] .. "</i>"
    ret[#ret+1] = p._vrow(frame, {"Cost", cost_arg, cost})
  end
  if not util._empty_arg(tech_trigger_arg) and tech_trigger_arg ~= "none" then
     ret[#ret+1] = p._vrow(frame, {"Researched by", tech_trigger_arg, parsing._technology_trigger(frame, tech_trigger_arg)})
  end
 
  ret[#ret+1] = p._extra    (frame,                          args["extra1"])
 
  if not util._empty_arg(args["map-color"]) then
    local color = frame:expandTemplate{title = 'Color', args = {args["map-color"]}}
    ret[#ret+1] = p._row(frame, {"Map color", args["map-color"], color})
   end
   end


   return string.format(
   ret[#ret+1] = p._row_simple(frame, "Map icon",              args["map-icon"])
  ret[#ret+1] = p._row_simple(frame, "Added in",              args["added-in"])
  ret[#ret+1] = p._row_simple(frame, "Walking speed",        args["walking-speed"])
  ret[#ret+1] = p._row_simple(frame, "Storage size",          util._arg_or(args["space-age-storage-size"], args["storage-size"]))
  ret[#ret+1] = p._row_simple(frame, "Fluid storage volume",  args["fluid-storage-volume"])
 
  if not util._empty_arg(args["expected-resources"]) then
    local label = p._translate(frame, "Expected resources")
    ret[#ret+1] = string.format(
[[<tr class="border-top">
[[<tr class="border-top">
<td colspan=2>
<td>
%s
%s
</td>
</td>
</tr>
<td style="width: 70%%;">
<tr>
<td class="infobox-vrow-value" colspan=2>
%s
%s
</td>
</td>
</tr>]],
</tr>]], label, args["expected-resources"])
     label,
  end
     content)
 
end
  ret[#ret+1] = p._row_simple(frame, "Health",                args["health"])
  ret[#ret+1] = p._row_unit  (frame, "Restores",              args["restores"],            "health")
  ret[#ret+1] = p._row_simple(frame, "Resistances",          args["resistance"])
  ret[#ret+1] = p._row_unit  (frame, "Lifespan",              args["lifespan"],            "seconds")
  ret[#ret+1] = p._row_simple(frame, "Inventory size bonus",  args["inventory-size-bonus"])
  ret[#ret+1] = p._row_simple(frame, "Equipment grid size",  args["grid-size"])
  ret[#ret+1] = p._row_simple(frame, "Stack size",            util._arg_or(args["space-age-stack-size"], args["stack-size"]))
  ret[#ret+1] = p._row_simple(frame, "Rocket capacity",      args["rocket-capacity"], sa)
  ret[#ret+1] = p._row_simple(frame, "Range",                args["range"])
  ret[#ret+1] = p._row_simple(frame, "Shooting speed",        args["shooting-speed"])
  ret[#ret+1] = p._row_simple(frame, "Damage",                args["damage"])
  ret[#ret+1] = p._row_simple(frame, "Damage bonus",          args["damage-bonus"])
  ret[#ret+1] = p._row_simple(frame, "Cluster size",          args["cluster-size"])
  ret[#ret+1] = p._row_simple(frame, "Area of effect size",  args["area-of-effect-size"])
  ret[#ret+1] = p._row_simple(frame, "Durability",            args["durability"])
  ret[#ret+1] = p._row_simple(frame, "Magazine size",        args["magazine-size"])
  ret[#ret+1] = p._row_item  (frame, "Ammunition",            args["ammunition"])
  ret[#ret+1] = p._vrow_item (frame, "Used as ammunition by", args["used-as-ammo-by"])
  ret[#ret+1] = p._row_simple(frame, "Efficiency",            args["efficiency"])
  ret[#ret+1] = p._row_simple(frame, "Dimensions",            args["dimensions"])
  ret[#ret+1] = p._row_type  (frame, "Energy consumption",    args["energy"])
  ret[#ret+1] = p._row_type  (frame, "Drain",                args["drain"])
  ret[#ret+1] = p._row_type  (frame, "Robot recharge rate",  args["robot-recharge-rate"])
  ret[#ret+1] = p._row_type  (frame, "Internal buffer recharge rate", args["internal-buffer-recharge-rate"])
  ret[#ret+1] = p._vrow_item (frame, "Placed in",            args["equipped-in"])
  ret[#ret+1] = p._row_simple(frame, "Robot limit",          args["robot-limit"])
  ret[#ret+1] = p._row_simple(frame, "Repair speed",          args["repair-speed"])
  ret[#ret+1] = p._row_simple(frame, "Charging stations",     args["charging-stations"])
  ret[#ret+1] = p._row_simple(frame, "Rotation speed",        args["rotation-speed"])
  ret[#ret+1] = p._row_simple(frame, "Belt speed",            args["belt-speed"])
  ret[#ret+1] = p._row_simple(frame, "Collection area",      args["asteroid-collection-area"])
  ret[#ret+1] = p._row_simple(frame, "Collection arm speed",  args["asteroid-collection-arm-speed"])
  ret[#ret+1] = p._row_simple(frame, "Collection arm count",  args["asteroid-collection-arm-count"])
  ret[#ret+1] = p._row_simple(frame, "Movement bonus",        args["movement-bonus"])
  ret[#ret+1] = p._row_type  (frame, "Energy capacity",      args["energy-capacity"])
  ret[#ret+1] = p._row_simple(frame, "Power input",          args["power-input"])
  ret[#ret+1] = p._row_simple(frame, "Power output",          args["power-output"])
  ret[#ret+1] = p._row_simple(frame, "Heat output",          args["heat-output"])
  ret[#ret+1] = p._row_simple(frame, "Maximum temperature",  args["maximum-temperature"])
  ret[#ret+1] = p._row_simple(frame, "Fluid consumption",    args["fluid-consumption"])
  ret[#ret+1] = p._row_simple(frame, "Shield hitpoints",      args["shield"])
  ret[#ret+1] = p._row_type  (frame, "Energy per hitpoint",  args["energy-per-hitpoint"])
  ret[#ret+1] = p._row_simple(frame, "Maximum recharge speed",args["maximum-recharge-speed"])
  ret[#ret+1] = p._row_simple(frame, "Crafting speed",        args["crafting-speed"])
  ret[#ret+1] = p._row_simple(frame, "Pumping speed",        args["pumping-speed"])
  ret[#ret+1] = p._row_simple(frame, "Mining time",          args["mining-time"])
  ret[#ret+1] = p._row_simple(frame, "Speed",                args["speed"])
  ret[#ret+1] = p._row_simple(frame, "Productivity",          args["productivity"])
  ret[#ret+1] = p._row_simple(frame, "Quality",              args["quality"])
  ret[#ret+1] = p._row_simple(frame, "Mining speed",          args["mining-speed"])
  ret[#ret+1] = p._row_unit  (frame, "Mining area",          args["mining-area"],          "tiles")
  ret[#ret+1] = p._row_simple(frame, "Resource drain",        args["resource-drain"])
  ret[#ret+1] = p._row_simple(frame, "Science pack drain",    args["science-pack-drain"])
  ret[#ret+1] = p._row_simple(frame, "Base productivity",    args["base-productivity"])
  ret[#ret+1] = p._row_type  (frame, "Fuel value",            args["fuel-value"])
  ret[#ret+1] = p._row_simple(frame, "Vehicle acceleration",  args["vehicle-acceleration"])
  ret[#ret+1] = p._row_simple(frame, "Vehicle top speed",    args["vehicle-top-speed"])
  ret[#ret+1] = p._row_unit  (frame, "Supply area",          args["supply-area"],          "tiles")
  ret[#ret+1] = p._row_unit  (frame, "Wire reach",            args["wire-reach"],            "tiles")
  ret[#ret+1] = p._row_unit  (frame, "Construction area",    args["construction-area"],    "tiles")
  ret[#ret+1] = p._row_simple(frame, "Pollution",             args["pollution"])
  ret[#ret+1] = p._row_item  (frame, "Buildable only on",     args["buildable-on"], sa)
  ret[#ret+1] = p._row_item  (frame, "Crafted only on",      args["crafted-on"], sa)
  ret[#ret+1] = p._row_unit  (frame, "Spoil time",            args["spoil-time"],            "minutes", sa)
  ret[#ret+1] = p._row_item  (frame, "Spoil result",          args["spoil-result"], sa)
  ret[#ret+1] = p._row_simple(frame, "Weight",                args["vehicle-weight"])
  ret[#ret+1] = p._row_unit  (frame, "Module slots",          args["modules"],              "slots")


function p.technology_parsing(frame)
  if not util._empty_arg(args["prototype-type"]) then
  local args = frame.args
    local prototype_type = frame:expandTemplate{title = 'Prototype page', args = {args["prototype-type"]}}
  if args[1] == "?" then
    ret[#ret+1] = p._row(frame, {"Prototype type", args["prototype-type"], prototype_type})
    return args[1] -- same as old template, likely not needed
   end
   end
  ret[#ret+1] = p._row_simple(frame, "Internal name",        args["internal-name"])


   local ret = {}
   ret[#ret+1] = p._vrow_item (frame, "Accepted equipment",    args["equipment"])
   local techs = p._split(args[1], "+")
   ret[#ret+1] = p._vrow_tech (frame, "Required technologies", util._arg_or(args["space-age-required-technologies"], args["required-technologies"]))
   for _, tech in ipairs(techs) do
  ret[#ret+1] = p._vrow_tech (frame, "Allows",                util._arg_or(args["space-age-allows"], args["allows"]))
    local tech_parts = p._split(tech, ",")
   ret[#ret+1] = p._vrow_item (frame, "Effects",               util._arg_or(args["space-age-effects"], args["effects"]))
    local tech_name = tech_parts[1] .. " (research)"
  ret[#ret+1] = p._vrow_tech (frame, "Boosting technologies", args["boosting-technologies"])
    if not p._page_exists(tech_name) then -- fall back to plain name if page with " (research)" doesn't exist
  ret[#ret+1] = p._vrow_item (frame, "Produced by",          util._arg_or(args["space-age-producers"], args["producers"]))
      tech_name = tech_parts[1]
  ret[#ret+1] = p._vrow_item (frame, "Consumed by",          util._arg_or(args["space-age-consumers"], args["consumers"]))
     end
  ret[#ret+1] = p._vrow_item (frame, "Valid fuel",            args["valid-fuel"])
  ret[#ret+1] = p._vrow_item (frame, "Used as fuel by",      args["used-as-fuel-by"])
  ret[#ret+1] = p._vrow_item (frame, "Recycling results",    args["recycling-results"], sa)
  ret[#ret+1] = p._extra     (frame,                          args["extra2"])


    local tech_level = tech_parts[2] or ""
    if tech_level == "" then -- fall back to level from tech name if none given manually
      local second_to_last_char = string.sub(tech_parts[1], -2, -2)
      if second_to_last_char == " " then
        tech_level = string.sub(tech_parts[1], -1) -- last character should be the level of the tech
      end
    end
    ret[#ret+1] = frame:expandTemplate{title = 'icon/special', args = {tech_name, tech_level, color=args.color or "999"}}
  end
   return table.concat(ret)
   return table.concat(ret)
end
end


function p.item_parsing(frame)
function p._translate(frame, str)
   local args = frame.args
   return frame:expandTemplate{title = "Translation", args = {str}}
  if args[1] == "?" then
end
    return args[1] -- same as old template, likely not needed
  end


  local ret = {}
function p._row_simple(frame, label, arg, label_prefix)
  local items = p._split(args[1], "+")
   if util._empty_arg(arg) or arg == "none" then return end
   for _, item in ipairs(items) do
    
    local icon_args = p._split(item, ",")
   return p._row(frame, {label, arg}, label_prefix)
    icon_args[2] = icon_args[2] or ""
    ret[#ret+1] = frame:expandTemplate{title = 'icon/special', args = icon_args}
   end
   return table.concat(ret)
end
end


function p._row_unit(frame, label, arg, unit, label_prefix)
  if util._empty_arg(arg) then return end
 
  return p._row(frame, {label, arg, arg .. " " .. p._translate(frame, unit)}, label_prefix)
end


function p.crafting_parsing(frame)
function p._row_type(frame, label, arg, label_prefix)
   local args = frame.args
   if util._empty_arg(arg) then return end
  if args[1] == "?" then
    return args[1] -- same as old template, likely not needed
  end
    
    
   local recipe_parts = p._split(args[1], "=")
   return p._row(frame, {label, arg, frame:expandTemplate{title = "Type", args = {arg}}}, label_prefix)
  local ingredients = p._crafting_parsing_split(frame, recipe_parts[1])
end
 
function p._row_item(frame, label, arg, label_prefix)
  if util._empty_arg(arg) then return end
    
    
   local products = recipe_parts[2]
   return p._row(frame, {label, arg, parsing._item(frame, arg)}, label_prefix)
  if products then
end
    products = "&rarr; " .. p._crafting_parsing_split(frame, products)
 
   else
function p._vrow_item(frame, label, arg, label_prefix)
    local item_name = frame:expandTemplate{title = 'No language suffix/No namespace'}
   if util._empty_arg(arg) or arg == "none" then return end
    products = "&rarr; " .. frame:expandTemplate{title = 'icon/special', args = {item_name, "1"}}
  end
    
    
   return ingredients .. products
   return p._vrow(frame, {label, arg, parsing._item(frame, arg)}, label_prefix)
end
end


function p.crafting_raw(frame)
function p._vrow_tech(frame, label, arg, label_prefix)
   local args = frame.args
   if util._empty_arg(arg) or arg == "none" then return end
  if args[1] == "?" then
    
    return args[1] -- same as old template, likely not needed
   return p._vrow(frame, {label, arg, parsing._technology(frame, {arg, color = "228B22"})}, label_prefix)
   end
 
   local recipe_parts = p._split(args[1], "=")
  return p._crafting_parsing_split(frame, recipe_parts[1])
end
end


-- @param frame
function p._row(frame, args, label_prefix)
-- @param str string A list of "item, count" separated by "+"
   if util._empty_arg(args[2]) then
-- @return string @The resulting icons with a "+" between each icon
     return
function p._crafting_parsing_split(frame, str)
  local ret = {}
  local items = p._split(str, "+")
   for _, item in ipairs(items) do
    local item_parts = p._split(item, ",")
    local item_count = item_parts[2] or "1" -- fall back to 1, not empty!
     item_count = frame:expandTemplate{title = 'Crop', args = {item_count}}
    ret[#ret+1] = frame:expandTemplate{title = 'icon/special', args = {item_parts[1], item_count}}
   end
   end
  return table.concat(ret, "+")
end


  local label = p._translate(frame, args[1])
  if label_prefix then
    label = label_prefix .. label
  end


function p._clean_arg(arg)
  return string.format(
if type(arg) == "string" then
[[<tr class="border-top">
arg = mw.text.trim(arg)
<td>
if arg == "" then
%s
return nil
</td>
else
<td>
return arg
%s
end
</td>
else
</tr>]],
return arg
    label,
end
    args[3] or args[2])
end
end


-- @param inputstr string A string to be split
function p._vrow(frame, args, label_prefix)
-- @param separator string The separator
   if util._empty_arg(args[2]) then
-- @return string[] @The separated strings, without the separator
    return
function p._split(inputstr, separator)
  end
   local result = {}


   for str in string.gmatch(inputstr, "([^"..separator.."]+)") do
   local label = p._translate(frame, args[1])
     table.insert(result, mw.text.trim(str))
  if label_prefix then
     label = label_prefix .. label
   end
   end


   return result
   return string.format(
[[<tr class="border-top">
<td colspan=2>
%s
</td>
</tr>
<tr>
<td class="infobox-vrow-value" colspan=2>
%s
</td>
</tr>]],
    label,
    args[3] or args[2])
end
end


-- @param page_title string The title of the page
function p._extra(frame, arg)
-- @return boolean
   if util._empty_arg(arg) then
function p._page_exists(page_title)
     return
   if page_title and page_title ~= "" then
    return mw.title.new(page_title).exists
  else
     return false
   end
   end
  local label = p._translate(frame, arg)
  return string.format(
[[<tr class="border-top">
<td colspan=2 class="infobox-extra">
%s
</td>
</tr>]],
    label)
end
end


return p
return p

Latest revision as of 04:21, 10 November 2024

Documentation for this module may be created at Module:Infobox/sandbox/doc

local util = require("Module:Util")
local parsing = require("Module:Infobox/parsing/sandbox")

local p = {}

function p.base_tab(frame) -- no prefix for args. Used for vanilla tab or if no tabs
  local args = frame:getParent().args
  local ret = {}
  local sa = frame:expandTemplate{title = "Space age"} .. " "

  if not util._empty_arg(args["recipe"]) then
    ret[#ret+1] = p._vrow(frame, {"Recipe",    args["recipe"], parsing._crafting(frame, args["recipe"])})
    ret[#ret+1] = p._vrow(frame, {"Total raw", args["recipe"], parsing._crafting_raw(frame, util._arg_or(args["total-raw"], args["recipe"]))})
  end

  if not util._empty_arg(args["cost"]) then
    local cost = parsing._item(frame, args["cost"]) .. ((not util._empty_arg(args["cost-multiplier"])) and "✖ <big>" .. args["cost-multiplier"] .. "</big>" or "")
    ret[#ret+1] = p._vrow(frame, {"Cost", args["cost"], cost})
  end
  if not util._empty_arg(args["technology-trigger"]) then
    ret[#ret+1] = p._vrow(frame, {"Researched by", args["technology-trigger"], parsing._technology_trigger(frame, args["technology-trigger"])})
  end

  ret[#ret+1] = p._extra     (frame,                          args["extra1"])
  
  if not util._empty_arg(args["map-color"]) then
    local color = frame:expandTemplate{title = 'Color', args = {args["map-color"]}}
    ret[#ret+1] = p._row(frame, {"Map color", args["map-color"], color})
  end

  ret[#ret+1] = p._row_simple(frame, "Map icon",              args["map-icon"])
  ret[#ret+1] = p._row_simple(frame, "Added in",              args["added-in"])
  ret[#ret+1] = p._row_simple(frame, "Walking speed",         args["walking-speed"])
  ret[#ret+1] = p._row_simple(frame, "Storage size",          args["storage-size"])
  ret[#ret+1] = p._row_simple(frame, "Fluid storage volume",  args["fluid-storage-volume"])

  if not util._empty_arg(args["expected-resources"]) then
    local label = p._translate(frame, "Expected resources")
    ret[#ret+1] = string.format(
[[<tr class="border-top">
<td>
%s
</td>
<td style="width: 70%%;">
%s
</td>
</tr>]], label, args["expected-resources"])
  end

  ret[#ret+1] = p._row_simple(frame, "Health",                args["health"])
  ret[#ret+1] = p._row_unit  (frame, "Restores",              args["restores"],             "health")
  ret[#ret+1] = p._row_simple(frame, "Resistances",           args["resistance"])
  ret[#ret+1] = p._row_unit  (frame, "Lifespan",              args["lifespan"],             "seconds")
  ret[#ret+1] = p._row_simple(frame, "Inventory size bonus",  args["inventory-size-bonus"])
  ret[#ret+1] = p._row_simple(frame, "Equipment grid size",   args["grid-size"])
  ret[#ret+1] = p._row_simple(frame, "Stack size",            args["stack-size"])
  ret[#ret+1] = p._row_simple(frame, "Rocket capacity",       args["rocket-capacity"], sa)
  ret[#ret+1] = p._row_simple(frame, "Range",                 args["range"])
  ret[#ret+1] = p._row_simple(frame, "Shooting speed",        args["shooting-speed"])
  ret[#ret+1] = p._row_simple(frame, "Damage",                args["damage"])
  ret[#ret+1] = p._row_simple(frame, "Damage bonus",          args["damage-bonus"])
  ret[#ret+1] = p._row_simple(frame, "Cluster size",          args["cluster-size"])
  ret[#ret+1] = p._row_simple(frame, "Area of effect size",   args["area-of-effect-size"])
  ret[#ret+1] = p._row_simple(frame, "Durability",            args["durability"])
  ret[#ret+1] = p._row_simple(frame, "Magazine size",         args["magazine-size"])
  ret[#ret+1] = p._row_item  (frame, "Ammunition",            args["ammunition"])
  ret[#ret+1] = p._vrow_item (frame, "Used as ammunition by", args["used-as-ammo-by"])
  ret[#ret+1] = p._row_simple(frame, "Efficiency",            args["efficiency"])
  ret[#ret+1] = p._row_simple(frame, "Dimensions",            args["dimensions"])
  ret[#ret+1] = p._row_type  (frame, "Energy consumption",    args["energy"])
  ret[#ret+1] = p._row_type  (frame, "Drain",                 args["drain"])
  ret[#ret+1] = p._row_type  (frame, "Robot recharge rate",   args["robot-recharge-rate"])
  ret[#ret+1] = p._row_type  (frame, "Internal buffer recharge rate", args["internal-buffer-recharge-rate"])
  ret[#ret+1] = p._vrow_item (frame, "Placed in",             args["equipped-in"])
  ret[#ret+1] = p._row_simple(frame, "Robot limit",           args["robot-limit"])
  ret[#ret+1] = p._row_simple(frame, "Repair speed",          args["repair-speed"])
  ret[#ret+1] = p._row_simple(frame, "Charging stations",     args["charging-stations"])
  ret[#ret+1] = p._row_simple(frame, "Rotation speed",        args["rotation-speed"])
  ret[#ret+1] = p._row_simple(frame, "Belt speed",            args["belt-speed"])
  ret[#ret+1] = p._row_simple(frame, "Collection area",       args["asteroid-collection-area"])
  ret[#ret+1] = p._row_simple(frame, "Collection arm speed",  args["asteroid-collection-arm-speed"])
  ret[#ret+1] = p._row_simple(frame, "Collection arm count",  args["asteroid-collection-arm-count"])
  ret[#ret+1] = p._row_simple(frame, "Movement bonus",        args["movement-bonus"])
  ret[#ret+1] = p._row_type  (frame, "Energy capacity",       args["energy-capacity"])
  ret[#ret+1] = p._row_simple(frame, "Power input",           args["power-input"])
  ret[#ret+1] = p._row_simple(frame, "Power output",          args["power-output"])
  ret[#ret+1] = p._row_simple(frame, "Heat output",           args["heat-output"])
  ret[#ret+1] = p._row_simple(frame, "Maximum temperature",   args["maximum-temperature"])
  ret[#ret+1] = p._row_simple(frame, "Fluid consumption",     args["fluid-consumption"])
  ret[#ret+1] = p._row_simple(frame, "Shield hitpoints",      args["shield"])
  ret[#ret+1] = p._row_type  (frame, "Energy per hitpoint",   args["energy-per-hitpoint"])
  ret[#ret+1] = p._row_simple(frame, "Maximum recharge speed",args["maximum-recharge-speed"])
  ret[#ret+1] = p._row_simple(frame, "Crafting speed",        args["crafting-speed"])
  ret[#ret+1] = p._row_simple(frame, "Pumping speed",         args["pumping-speed"])
  ret[#ret+1] = p._row_simple(frame, "Mining time",           args["mining-time"])
  ret[#ret+1] = p._row_simple(frame, "Speed",                 args["speed"])
  ret[#ret+1] = p._row_simple(frame, "Productivity",          args["productivity"])
  ret[#ret+1] = p._row_simple(frame, "Quality",               args["quality"], sa)
  ret[#ret+1] = p._row_simple(frame, "Mining speed",          args["mining-speed"])
  ret[#ret+1] = p._row_unit  (frame, "Mining area",           args["mining-area"],           "tiles")
  ret[#ret+1] = p._row_simple(frame, "Resource drain",        args["resource-drain"])
  ret[#ret+1] = p._row_simple(frame, "Science pack drain",    args["science-pack-drain"])
  ret[#ret+1] = p._row_simple(frame, "Base productivity",     args["base-productivity"])
  ret[#ret+1] = p._row_type  (frame, "Fuel value",            args["fuel-value"])
  ret[#ret+1] = p._row_simple(frame, "Vehicle acceleration",  args["vehicle-acceleration"])
  ret[#ret+1] = p._row_simple(frame, "Vehicle top speed",     args["vehicle-top-speed"])
  ret[#ret+1] = p._row_unit  (frame, "Supply area",           args["supply-area"],           "tiles")
  ret[#ret+1] = p._row_unit  (frame, "Wire reach",            args["wire-reach"],            "tiles")
  ret[#ret+1] = p._row_unit  (frame, "Construction area",     args["construction-area"],     "tiles")
  ret[#ret+1] = p._row_simple(frame, "Pollution",             args["pollution"])
  ret[#ret+1] = p._row_item  (frame, "Buildable only on",     args["buildable-on"], sa)
  ret[#ret+1] = p._row_item  (frame, "Crafted only on",       args["crafted-on"], sa)
  ret[#ret+1] = p._row_unit  (frame, "Spoil time",            args["spoil-time"],            "minutes", sa)
  ret[#ret+1] = p._row_item  (frame, "Spoil result",          args["spoil-result"], sa)
  ret[#ret+1] = p._row_simple(frame, "Weight",                args["vehicle-weight"])
  ret[#ret+1] = p._row_unit  (frame, "Module slots",          args["modules"],               "slots")

  if not util._empty_arg(args["prototype-type"]) then
    local prototype_type = frame:expandTemplate{title = 'Prototype page', args = {args["prototype-type"]}}
    ret[#ret+1] = p._row(frame, {"Prototype type", args["prototype-type"], prototype_type})
  end
  ret[#ret+1] = p._row_simple(frame, "Internal name",         args["internal-name"])

  ret[#ret+1] = p._vrow_item (frame, "Accepted equipment",    args["equipment"])
  ret[#ret+1] = p._vrow_tech (frame, "Required technologies", args["required-technologies"])
  ret[#ret+1] = p._vrow_tech (frame, "Allows",                args["allows"])
  ret[#ret+1] = p._vrow_item (frame, "Effects",               args["effects"])
  ret[#ret+1] = p._vrow_tech (frame, "Boosting technologies", args["boosting-technologies"])
  ret[#ret+1] = p._vrow_item (frame, "Produced by",           args["producers"])
  ret[#ret+1] = p._vrow_item (frame, "Consumed by",           args["consumers"])
  ret[#ret+1] = p._vrow_item (frame, "Valid fuel",            args["valid-fuel"])
  ret[#ret+1] = p._vrow_item (frame, "Used as fuel by",       args["used-as-fuel-by"])
  ret[#ret+1] = p._vrow_item (frame, "Recycling results",     args["recycling-results"], sa)
  ret[#ret+1] = p._extra     (frame,                          args["extra2"])

  return table.concat(ret)
end

function p.space_age_tab(frame) -- space-age prefix for some args. Used for space age mod tab
  local args = frame:getParent().args
  local ret = {}
  local sa = frame:expandTemplate{title = "Space age"} .. " "
  
  local recipe = util._arg_or(args["space-age-recipe"], args["recipe"])
  if not util._empty_arg(recipe) then
    ret[#ret+1] = p._vrow(frame, {"Recipe",    recipe, parsing._crafting(frame, recipe)})
    local vanilla_total_raw = util._arg_or(args["total-raw"], args["recipe"])
    ret[#ret+1] = p._vrow(frame, {"Total raw", recipe, parsing._crafting_raw(frame, util._arg_or(args["space-age-total-raw"],  util._arg_or(args["space-age-recipe"], vanilla_total_raw)))})
  end

  local cost_arg = util._arg_or(args["space-age-cost"], args["cost"])
  local tech_trigger_arg = util._arg_or(args["space-age-technology-trigger"], args["technology-trigger"])
  if not util._empty_arg(cost_arg) and cost_arg ~= "none" then
    local cost_multiplier_arg = util._arg_or(args["space-age-cost-multiplier"], args["cost-multiplier"])
    local cost = parsing._item(frame, cost_arg) .. ((not util._empty_arg(cost_multiplier_arg)) and "✖ <big>" .. cost_multiplier_arg .. "</big>" or "")
    ret[#ret+1] = p._vrow(frame, {"Cost", cost_arg, cost})
  end
  if not util._empty_arg(tech_trigger_arg) and tech_trigger_arg ~= "none" then
    ret[#ret+1] = p._vrow(frame, {"Researched by", tech_trigger_arg, parsing._technology_trigger(frame, tech_trigger_arg)})
  end

  ret[#ret+1] = p._extra     (frame,                          args["extra1"])
  
  if not util._empty_arg(args["map-color"]) then
    local color = frame:expandTemplate{title = 'Color', args = {args["map-color"]}}
    ret[#ret+1] = p._row(frame, {"Map color", args["map-color"], color})
  end

  ret[#ret+1] = p._row_simple(frame, "Map icon",              args["map-icon"])
  ret[#ret+1] = p._row_simple(frame, "Added in",              args["added-in"])
  ret[#ret+1] = p._row_simple(frame, "Walking speed",         args["walking-speed"])
  ret[#ret+1] = p._row_simple(frame, "Storage size",          util._arg_or(args["space-age-storage-size"], args["storage-size"]))
  ret[#ret+1] = p._row_simple(frame, "Fluid storage volume",  args["fluid-storage-volume"])

  if not util._empty_arg(args["expected-resources"]) then
    local label = p._translate(frame, "Expected resources")
    ret[#ret+1] = string.format(
[[<tr class="border-top">
<td>
%s
</td>
<td style="width: 70%%;">
%s
</td>
</tr>]], label, args["expected-resources"])
  end

  ret[#ret+1] = p._row_simple(frame, "Health",                args["health"])
  ret[#ret+1] = p._row_unit  (frame, "Restores",              args["restores"],             "health")
  ret[#ret+1] = p._row_simple(frame, "Resistances",           args["resistance"])
  ret[#ret+1] = p._row_unit  (frame, "Lifespan",              args["lifespan"],             "seconds")
  ret[#ret+1] = p._row_simple(frame, "Inventory size bonus",  args["inventory-size-bonus"])
  ret[#ret+1] = p._row_simple(frame, "Equipment grid size",   args["grid-size"])
  ret[#ret+1] = p._row_simple(frame, "Stack size",            util._arg_or(args["space-age-stack-size"], args["stack-size"]))
  ret[#ret+1] = p._row_simple(frame, "Rocket capacity",       args["rocket-capacity"], sa)
  ret[#ret+1] = p._row_simple(frame, "Range",                 args["range"])
  ret[#ret+1] = p._row_simple(frame, "Shooting speed",        args["shooting-speed"])
  ret[#ret+1] = p._row_simple(frame, "Damage",                args["damage"])
  ret[#ret+1] = p._row_simple(frame, "Damage bonus",          args["damage-bonus"])
  ret[#ret+1] = p._row_simple(frame, "Cluster size",          args["cluster-size"])
  ret[#ret+1] = p._row_simple(frame, "Area of effect size",   args["area-of-effect-size"])
  ret[#ret+1] = p._row_simple(frame, "Durability",            args["durability"])
  ret[#ret+1] = p._row_simple(frame, "Magazine size",         args["magazine-size"])
  ret[#ret+1] = p._row_item  (frame, "Ammunition",            args["ammunition"])
  ret[#ret+1] = p._vrow_item (frame, "Used as ammunition by", args["used-as-ammo-by"])
  ret[#ret+1] = p._row_simple(frame, "Efficiency",            args["efficiency"])
  ret[#ret+1] = p._row_simple(frame, "Dimensions",            args["dimensions"])
  ret[#ret+1] = p._row_type  (frame, "Energy consumption",    args["energy"])
  ret[#ret+1] = p._row_type  (frame, "Drain",                 args["drain"])
  ret[#ret+1] = p._row_type  (frame, "Robot recharge rate",   args["robot-recharge-rate"])
  ret[#ret+1] = p._row_type  (frame, "Internal buffer recharge rate", args["internal-buffer-recharge-rate"])
  ret[#ret+1] = p._vrow_item (frame, "Placed in",             args["equipped-in"])
  ret[#ret+1] = p._row_simple(frame, "Robot limit",           args["robot-limit"])
  ret[#ret+1] = p._row_simple(frame, "Repair speed",          args["repair-speed"])
  ret[#ret+1] = p._row_simple(frame, "Charging stations",     args["charging-stations"])
  ret[#ret+1] = p._row_simple(frame, "Rotation speed",        args["rotation-speed"])
  ret[#ret+1] = p._row_simple(frame, "Belt speed",            args["belt-speed"])
  ret[#ret+1] = p._row_simple(frame, "Collection area",       args["asteroid-collection-area"])
  ret[#ret+1] = p._row_simple(frame, "Collection arm speed",  args["asteroid-collection-arm-speed"])
  ret[#ret+1] = p._row_simple(frame, "Collection arm count",  args["asteroid-collection-arm-count"])
  ret[#ret+1] = p._row_simple(frame, "Movement bonus",        args["movement-bonus"])
  ret[#ret+1] = p._row_type  (frame, "Energy capacity",       args["energy-capacity"])
  ret[#ret+1] = p._row_simple(frame, "Power input",           args["power-input"])
  ret[#ret+1] = p._row_simple(frame, "Power output",          args["power-output"])
  ret[#ret+1] = p._row_simple(frame, "Heat output",           args["heat-output"])
  ret[#ret+1] = p._row_simple(frame, "Maximum temperature",   args["maximum-temperature"])
  ret[#ret+1] = p._row_simple(frame, "Fluid consumption",     args["fluid-consumption"])
  ret[#ret+1] = p._row_simple(frame, "Shield hitpoints",      args["shield"])
  ret[#ret+1] = p._row_type  (frame, "Energy per hitpoint",   args["energy-per-hitpoint"])
  ret[#ret+1] = p._row_simple(frame, "Maximum recharge speed",args["maximum-recharge-speed"])
  ret[#ret+1] = p._row_simple(frame, "Crafting speed",        args["crafting-speed"])
  ret[#ret+1] = p._row_simple(frame, "Pumping speed",         args["pumping-speed"])
  ret[#ret+1] = p._row_simple(frame, "Mining time",           args["mining-time"])
  ret[#ret+1] = p._row_simple(frame, "Speed",                 args["speed"])
  ret[#ret+1] = p._row_simple(frame, "Productivity",          args["productivity"])
  ret[#ret+1] = p._row_simple(frame, "Quality",               args["quality"])
  ret[#ret+1] = p._row_simple(frame, "Mining speed",          args["mining-speed"])
  ret[#ret+1] = p._row_unit  (frame, "Mining area",           args["mining-area"],           "tiles")
  ret[#ret+1] = p._row_simple(frame, "Resource drain",        args["resource-drain"])
  ret[#ret+1] = p._row_simple(frame, "Science pack drain",    args["science-pack-drain"])
  ret[#ret+1] = p._row_simple(frame, "Base productivity",     args["base-productivity"])
  ret[#ret+1] = p._row_type  (frame, "Fuel value",            args["fuel-value"])
  ret[#ret+1] = p._row_simple(frame, "Vehicle acceleration",  args["vehicle-acceleration"])
  ret[#ret+1] = p._row_simple(frame, "Vehicle top speed",     args["vehicle-top-speed"])
  ret[#ret+1] = p._row_unit  (frame, "Supply area",           args["supply-area"],           "tiles")
  ret[#ret+1] = p._row_unit  (frame, "Wire reach",            args["wire-reach"],            "tiles")
  ret[#ret+1] = p._row_unit  (frame, "Construction area",     args["construction-area"],     "tiles")
  ret[#ret+1] = p._row_simple(frame, "Pollution",             args["pollution"])
  ret[#ret+1] = p._row_item  (frame, "Buildable only on",     args["buildable-on"], sa)
  ret[#ret+1] = p._row_item  (frame, "Crafted only on",       args["crafted-on"], sa)
  ret[#ret+1] = p._row_unit  (frame, "Spoil time",            args["spoil-time"],            "minutes", sa)
  ret[#ret+1] = p._row_item  (frame, "Spoil result",          args["spoil-result"], sa)
  ret[#ret+1] = p._row_simple(frame, "Weight",                args["vehicle-weight"])
  ret[#ret+1] = p._row_unit  (frame, "Module slots",          args["modules"],               "slots")

  if not util._empty_arg(args["prototype-type"]) then
    local prototype_type = frame:expandTemplate{title = 'Prototype page', args = {args["prototype-type"]}}
    ret[#ret+1] = p._row(frame, {"Prototype type", args["prototype-type"], prototype_type})
  end
  ret[#ret+1] = p._row_simple(frame, "Internal name",         args["internal-name"])

  ret[#ret+1] = p._vrow_item (frame, "Accepted equipment",    args["equipment"])
  ret[#ret+1] = p._vrow_tech (frame, "Required technologies", util._arg_or(args["space-age-required-technologies"], args["required-technologies"]))
  ret[#ret+1] = p._vrow_tech (frame, "Allows",                util._arg_or(args["space-age-allows"], args["allows"]))
  ret[#ret+1] = p._vrow_item (frame, "Effects",               util._arg_or(args["space-age-effects"], args["effects"]))
  ret[#ret+1] = p._vrow_tech (frame, "Boosting technologies", args["boosting-technologies"])
  ret[#ret+1] = p._vrow_item (frame, "Produced by",           util._arg_or(args["space-age-producers"], args["producers"]))
  ret[#ret+1] = p._vrow_item (frame, "Consumed by",           util._arg_or(args["space-age-consumers"], args["consumers"]))
  ret[#ret+1] = p._vrow_item (frame, "Valid fuel",            args["valid-fuel"])
  ret[#ret+1] = p._vrow_item (frame, "Used as fuel by",       args["used-as-fuel-by"])
  ret[#ret+1] = p._vrow_item (frame, "Recycling results",     args["recycling-results"], sa)
  ret[#ret+1] = p._extra     (frame,                          args["extra2"])

  return table.concat(ret)
end

function p._translate(frame, str)
  return frame:expandTemplate{title = "Translation", args = {str}}
end

function p._row_simple(frame, label, arg, label_prefix)
  if util._empty_arg(arg) or arg == "none" then return end
  
  return p._row(frame, {label, arg}, label_prefix)
end

function p._row_unit(frame, label, arg, unit, label_prefix)
  if util._empty_arg(arg) then return end
  
  return p._row(frame, {label, arg, arg .. " " .. p._translate(frame, unit)}, label_prefix)
end

function p._row_type(frame, label, arg, label_prefix)
  if util._empty_arg(arg) then return end
  
  return p._row(frame, {label, arg, frame:expandTemplate{title = "Type", args = {arg}}}, label_prefix)
end

function p._row_item(frame, label, arg, label_prefix)
  if util._empty_arg(arg) then return end
  
  return p._row(frame, {label, arg, parsing._item(frame, arg)}, label_prefix)
end

function p._vrow_item(frame, label, arg, label_prefix)
  if util._empty_arg(arg) or arg == "none" then return end
  
  return p._vrow(frame, {label, arg, parsing._item(frame, arg)}, label_prefix)
end

function p._vrow_tech(frame, label, arg, label_prefix)
  if util._empty_arg(arg) or arg == "none" then return end
  
  return p._vrow(frame, {label, arg, parsing._technology(frame, {arg, color = "228B22"})}, label_prefix)
end

function p._row(frame, args, label_prefix)
  if util._empty_arg(args[2]) then
    return
  end

  local label = p._translate(frame, args[1])
  if label_prefix then
    label = label_prefix .. label
  end

  return string.format(
[[<tr class="border-top">
<td>
%s
</td>
<td>
%s
</td>
</tr>]],
    label,
    args[3] or args[2])
end

function p._vrow(frame, args, label_prefix)
  if util._empty_arg(args[2]) then
    return
  end

  local label = p._translate(frame, args[1])
  if label_prefix then
    label = label_prefix .. label
  end

  return string.format(
[[<tr class="border-top">
<td colspan=2>
%s
</td>
</tr>
<tr>
<td class="infobox-vrow-value" colspan=2>
%s
</td>
</tr>]],
    label,
    args[3] or args[2])
end

function p._extra(frame, arg)
  if util._empty_arg(arg) then
    return
  end

  local label = p._translate(frame, arg)

  return string.format(
[[<tr class="border-top">
<td colspan=2 class="infobox-extra">
%s
</td>
</tr>]],
    label)
end

return p