Editing Module:Infobox Item

From Eco - English Wiki

Your changes will be displayed to readers once an authorized user accepts them. (help)

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 6: Line 6:


-- Build an Item Infobox
-- Build an Item Infobox
function itemBox(args, itemData)
function itemBox( args, itemData )
    -- check that all necessary arguments are passed correctly
  -- check that all necessary arguments are passed correctly
    if args.name == nil or args.name == '' then
  if args.name == nil or args.name == '' then
        return '\'name\' must be specified.'
    return '\'name\' must be specified.'
    end
  end


    local item = args.name
  local item = args.name
    local itemTable = itemData.items[item]
  local itemTable = itemData.items[item]


    if itemTable == nil then
  if itemTable == nil then
        return item .. ' could not be found in Module:ItemData. [[Category:MissingItem]]'
    return item .. ' could not be found in Module:ItemData.'
    end
  end


    local itemType = itemTable.type
  local itemType = itemTable.type
    local itemEN = string.sub(itemType, 1, -5)
  local itemEN = string.sub (itemType, 1, -5)
    local itemimagename = string.gsub(itemEN, ' ', '')
  local itemimagename = string.gsub(itemEN, ' ', '')


    -- string used to build the infobox
  -- string used to build the infobox
    local infobox = '{| class=\"infobox\"\n'
  local infobox = '{| class=\"infobox\"\n'


    -- 'Name and Image' section
  -- 'Name and Image' section
    -- name of the item
  -- name of the item
    infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. item .. '</big>\'\'\'\n'
  infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. item .. '</big>\'\'\'\n'


    -- the item's type (ItemData - group)
  -- the item's type (ItemData - group)
    infobox = infobox .. '|- style=\"text-align: center; color: white; background-color: '
  infobox = infobox .. '|- style=\"text-align: center; color: white; background-color: '


     local text_colour = '#78B1FF'
  if itemTable.group == 'Food' then
    infobox = infobox .. '#85D66B;\"\n| colspan=\"2\" | \'\'\'Food\'\'\'\n'
    -- Items:Food Icon Image
     local image = checkImage(itemimagename, 'Icon')


     if itemTable.group == L.t('Food') then
     infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | <div class="iconContainer"><div class="iconStack">[[File:' .. image .. '|frameless|class=iconGreen]]</div><div class=iconBorder style=\"position:absolute;\"></div></div> \n'
        text_colour = '#85D66B'
    elseif itemTable.group == L.t('Skill Books') or itemTable.group == L.t('Skill Scrolls') then
        text_colour = '#FFCF4D'
    elseif itemTable.group == L.t('Skill Scrolls') then
        text_colour = '#FFCF4D'
    end


     infobox = infobox .. text_colour .. ';\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
  elseif itemTable.group == 'Skill Books' then
     local icon = Utils.checkImage(itemTable.type)
     infobox = infobox .. '#FFCF4D;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
     infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | '..icon .. '\n'
     -- Items:Skill Book Icon Image
     infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | <div class="iconContainer"><div class="iconStack">[[File:SkillBook.png|link=https://wiki.play.eco/File:SkillBook.png|frameless|class=iconGold]]</div><div class=iconBorder style=\"position:absolute;\"></div></div> \n'


     -- 'Description' section header
  elseif itemTable.group == 'Skill Scrolls' then
     infobox = infobox .. sectionHeader('Description')
    infobox = infobox .. '#FFCF4D;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
     -- Items:Skill Scrolls Icon Image
     infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | <div class="iconContainer"><div class="iconStack">[[File:SkillScroll.png|link=https://wiki.play.eco/File:SkillScroll.png|frameless|class=iconGold]]</div><div class=iconBorder style=\"position:absolute;\"></div></div> \n'


     if itemTable.description == nil or itemTable.description == '' then
  else
        infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'' .. L.t('None') .. '\'\'\'\n'
     infobox = infobox .. '#78B1FF;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
     else
     -- Items: Other Icon Image
        infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. itemTable.description .. '\n'
    local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Icon.png|[[Category:Pages_with_missing_icon]]'
    if mw.title.makeTitle('File', itemimagename .. '_Icon.png').file.exists then
      image = itemimagename .. '_Icon.png'
    elseif mw.title.makeTitle('File', itemimagename .. '_Icon.jpg').file.exists then
      image = itemimagename .. '_Icon.jpg'
     end
     end
    infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | <div class="iconContainer"><div class="iconStack">[[File:' .. image .. '|frameless|class=iconBlue]]</div><div class=iconBorder style=\"position:absolute;\"></div></div> \n'
  end


    --Crafting
  -- 'Description' section header
    local craftingRecipes = mw.loadData("Module:CraftingRecipes")
  infobox = infobox .. sectionHeader('Description')


     infobox = infobox .. generalSection(item, itemTable, craftingRecipes, args)
  if itemTable.description == nil then
     infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
  elseif itemTable.description == '' then
    infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
  else
    infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. itemTable.description .. '\n'
  end


    infobox = infobox .. IDsSection(itemTable)
  --Crafting
  local craftingRecipes = mw.loadData( "Module:CraftingRecipes" )


    -- Tags Header
  infobox = infobox .. IDsSection(itemTable)
    if itemTable.tagGroups ~= nil and itemTable.tagGroups ~= {} then
        infobox = infobox .. tagSection(itemTable, itemData)
    end


    -- 'Item' World Object header (if itemTable.group = Placeable or Blocks)
  -- Tags Header
    if itemTable.footprint ~= nil then
  if itemTable.tagGroups ~= nil and itemTable.tagGroups ~= {} then
        infobox = infobox .. placementSection(itemTable, itemimagename)
    infobox = infobox .. tagSection(itemTable, itemData)
  end


        -- Object Form Image
  -- 'Item' World Object header (if itemTable.group = Placeable or Blocks)
        if itemTable.group == L.t('Block Items') then
  if itemTable.group == 'Block Items' or itemTable.group == 'World Object Items' then
            infobox = infobox .. objectFormSection(itemTable, itemimagename)
    infobox = infobox .. placementSection(itemTable, itemimagename)
        end


        -- 'Housing' section (if there is a Room Category)
    -- Object Form Image
        if itemTable.roomCategory ~= nil then
    if itemTable.group == 'Block Items' then
            infobox = infobox .. housingSection(itemTable)
      infobox = infobox .. objectFormSection(itemTable, itemimagename)
        end
    end


        -- 'Storage' Section (if inventorySlots is not nil)
    -- 'Housing' section (if there is a Room Category)
        if itemTable.inventorySlots ~= nil then
    if itemTable.roomCategory ~= nil then
            infobox = infobox .. storageSection(itemTable)
      infobox = infobox .. housingSection(itemTable)
        end
    end


        -- 'Power' section (if EngeryType is ``not nil)
    -- 'Storage' Section (if inventorySlots is not nil)
        if itemTable.energyType ~= nil then
    if itemTable.inventorySlots ~= nil then
            infobox = infobox .. powerSection(itemTable)
      infobox = infobox .. storageSection(itemTable)
    end


        end
    -- 'Power' section (if EngeryType is ``not nil)
    if itemTable.energyType ~= nil then 
      infobox = infobox .. powerSection(itemTable)


        -- 'Fuel' Section (if fuelsUsed by Object)
    end
        if itemTable.fuelsUsed ~= nil then
            infobox = infobox .. fuelsSection(itemTable)
        end


        -- 'Fluid' section (if fludisUsed is not nil)
    -- 'Fuel' Section (if fuelsUsed by Object)
        if itemTable.fluidsUsed ~= nil or itemTable.fluidsProduced ~= nil then
    if itemTable.fuelsUsed ~= nil then
            infobox = infobox .. fluidsSection(itemTable)
      infobox = infobox .. fuelsSection(itemTable)
        end
     end
     end


     -- Road Object header (if group == Road Items)
     -- 'Fluid' section (if fludisUsed is not nil)  
     if itemTable.group == L.t('Road Items') then
     if itemTable.fluidsUsed ~= nil or itemTable.fluidsProduced ~= nil then  
        infobox = infobox .. roadItemsSection(itemTable, itemimagename)
      infobox = infobox .. fluidsSection(itemTable)
     end
     end
     infobox = infobox .. '|}'
  end
    return infobox
 
  -- Road Object header (if group == Road Items)
  if itemTable.group == 'Road Items' then
     infobox = infobox .. roadItemsSection(itemTable, itemimagename)
  end
  infobox = infobox .. '|}'
  return infobox
end
end


function sectionHeader(title, count)
local function addToSet(set, key)
    return "|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | '''" .. L.t(title, count) .. "'''\n"
  set[key] = true
end
end


function sectionRow(label, content, count, unit)
local function setNotContains(set, key)
    if unit ~= nil then
  return set[key] == nil
        content = tonumber(content)
        unit = L.t(unit, content)
        local lang = mw.getContentLanguage()
        content = lang:formatNum(content)
    else
        unit = ''
    end
    return '|-\n| ' .. L.t(label, count) .. ':\n| style=\"text-align: right; padding: 3px;\" | ' .. content .. unit .. '\n'
end
end


function sectionImage(imageName, suffix)
function generalSection(itemTable, craftingRecipes)
    local image = checkImage(imageName, suffix)
-- 'General' section header
    return '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
  section = sectionHeader('General')
end


local function addToSet(set, key)
  local recipes = craftingRecipes.recipes
    set[key] = true
end


local function setNotContains(set, key)
    return set[key] == nil
end


local function craftingSubSection(title, item, productsOrIngredients, recipes)
  -- Is a product at these tables
  if craftingRecipes.products[item] ~= nil and #craftingRecipes.products[item] >= 1 then
    local count = 0
     local stations = {}
     local stations = {}
     local sortStations = {}
     local sortStations = {}
     local stationString = ''
     local stationString = ''
     for _, recipeName in ipairs(productsOrIngredients[item]) do
    local found = false
        local currentRecipe = recipes[recipeName]
     for k, v in ipairs( craftingRecipes.products[item] ) do
        if currentRecipe ~= nil then
      if recipes[v] ~= nil then
            if currentRecipe.variants[recipeName] ~= nil then
        for num = 1, #recipes[v].numberOfVariants do
                local currentStation = currentRecipe.craftStn[1][1]
          if (recipes[v].variants[v] ~= nil and recipes[v].numberOfVariants <= tostring(1)) then
                if setNotContains(stations, currentStation) then
            if setNotContains(stations, recipes[v].craftStn[1][1]) then
                    addToSet(stations, currentStation)
              addToSet(stations, recipes[v].craftStn[1][1])
                end
              count = count + 1
            end
            if found == false then
              found = true
              infobox = infobox .. '|-\n| Created At:\n| style=\"text-align: right; padding: 3px;\" |'
             end
             end
          end
         end
         end
      end
     end
     end


     if stations then
    local track = 0
        for a, _ in pairs(stations) do
 
            table.insert(sortStations, a)
     if found == true then
      for a, b in pairs(stations) do
        table.insert(sortStations, a)
      end
      table.sort(sortStations)
      for i, n in ipairs(sortStations) do
        stationString = stationString .. ' [[' .. n .. ']]'
        track = track + 1
        if track ~= count then -- Changed these line to produce comma if not last table.
          stationString = stationString .. ','
         end
         end
        table.sort(sortStations)
      end
        for i, n in ipairs(sortStations) do
      infobox = infobox .. stationString .. '\n'
            stationString = stationString .. ' [[' .. n .. ']]'
    else
             if (n ~= sortStations[#sortStations]) then
      infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right; padding: 3px;\" | N/A\n'
                -- add a comma
    end
                stationString = stationString .. ', '
  end
 
  -- Is an ingredient at these tables
  if craftingRecipes.ingredients[item] ~= nil and #craftingRecipes.ingredients[item] >= 1 then
    local count = 0
    local stations = {}
    local sortStations = {}
    local stationString = ''
    local found = false
    for k, v in ipairs( craftingRecipes.ingredients[item] ) do
      if recipes[v] ~= nil then
        for num = 1, #recipes[v].numberOfVariants do
          if (recipes[v].variants[v] ~= nil and recipes[v].numberOfVariants <= tostring(1)) then
            if setNotContains(stations, recipes[v].craftStn[1][1]) then
              addToSet(stations, recipes[v].craftStn[1][1])
              count = count + 1
            end
             if found == false then
              found = true
              infobox = infobox .. '|-\n| Used At:\n| style=\"text-align: right; padding: 3px;\" |'
             end
             end
          end
         end
         end
        return sectionRow(title, stationString)
      end
    else
        return sectionRow(title, L.t('N/A'))
     end
     end
end


function generalSection(item, itemTable, craftingRecipes, args)
     local track = 0
     -- 'General' section header
    section = sectionHeader('General')


     -- Is a product at these tables
     if found == true then
    if craftingRecipes.products[item] ~= nil and Utils.tableLen(craftingRecipes.products[item]) >= 1 then
      for a, b in pairs(stations) do
         section = section .. craftingSubSection('Created at', item, craftingRecipes.products, craftingRecipes.recipes)
        table.insert(sortStations, a)
      end
      table.sort(sortStations)
      for i, n in ipairs(sortStations) do
        stationString = stationString .. ' [[' .. n .. ']]'
        track = track + 1
        if track ~= count then -- Changed these line to produce comma if not last table.
          stationString = stationString .. ','
         end
      end
      infobox = infobox .. stationString .. '\n'
    else
      infobox = infobox .. '|-\n| Used at:\n| style=\"text-align: right; padding: 3px;\" | N/A\n'
     end
     end
  end


     -- Is an ingredient at these tables
  -- calories and nutrients (if itemTable.group == 'Food')
     if craftingRecipes.ingredients[item] ~= nil and Utils.tableLen(craftingRecipes.ingredients[item]) >= 1 then
  if itemTable.group == 'Food' then
        section = section .. craftingSubSection('Used at', item, craftingRecipes.ingredients, craftingRecipes.recipes)
     infobox = infobox .. '|-\n| Calories:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.calories .. '\n|- valign=\"center\"\n| rowspan=\"4\" | Nutrients:\n'
     end
    infobox = infobox .. '| style=\"color: red; text-align: right; padding: 3px;\" | Carbs: ' .. itemTable.carbs .. '\n'
     infobox = infobox .. '|- valign=\"center\"\n| style=\"color: orange; text-align: right; padding: 3px;\" | Protein: ' .. itemTable.protein .. '\n'
    infobox = infobox .. '|- valign=\"center\"\n| style=\"color: yellow; text-align: right; padding: 3px;\" | Fat: ' .. itemTable.fat .. '\n'
    infobox = infobox .. '|- valign=\"center\"\n| style=\"color: limegreen; text-align: right; padding: 3px;\" | Vitamins: ' .. itemTable.vitamins .. '\n'
     infobox = infobox .. '|-\n| Nutrition Density:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.density .. ' per 100 cals\n'
  end


    -- calories and nutrients (if itemTable.group == 'Food')
  -- carried
    if itemTable.group == L.t('Food') then
  if args.carried ~= nil and args.carried ~= '' then
        section = section .. sectionRow('Calorie', itemTable.calories, tonumber(itemTable.calories), 'cal')
    infobox = infobox .. '|-\n| Carried in:\n| style=\"text-align: right; padding: 3px;\" | ' .. args.carried .. '\n'
        section = section .. '|- valign=\"center\"\n| rowspan=\"4\" | ' .. L.t('Nutrients') .. ':\n'
  else
        section = section .. '| style=\"color: red; text-align: right; padding: 3px;\" | ' .. L.t('Carbs') .. ': ' .. itemTable.carbs .. '\n'
    infobox = infobox .. '|-\n| Carried in:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.carried .. '\n'
        section = section .. '|- valign=\"center\"\n| style=\"color: orange; text-align: right; padding: 3px;\" | ' .. L.t('Protein') .. ': ' .. itemTable.protein .. '\n'
  end
        section = section .. '|- valign=\"center\"\n| style=\"color: darkkhaki; text-align: right; padding: 3px;\" | ' .. L.t('Fat') .. ': ' .. itemTable.fat .. '\n'
        section = section .. '|- valign=\"center\"\n| style=\"color: limegreen; text-align: right; padding: 3px;\" | ' .. L.t('Vitamins') .. ': ' .. itemTable.vitamins .. '\n'
        section = section .. sectionRow('Nutrition Density', L.t('%s per 100 cals'):format(itemTable.density))
    end


    -- carried
  -- weight
    local carried
  if itemTable.weight ~= nil then
    if args.carried ~= nil and args.carried ~= '' then
    infobox = infobox .. '|-\n| Weight:\n| style="text-align: right; padding: 3px;" | ' .. itemTable.weight .. ' kg\n'
        carried = args.carried
  else
    else
     infobox = infobox .. '|-\n| Weight:\n| style="text-align: right; padding: 3px;" | 0.00kg\n'
        carried = itemTable.carried
  end
    end
     section = section .. sectionRow('Carried in', carried)


    -- weight
  -- stack limit
    local weight
  if itemTable.maxStack ~= nil then
    if itemTable.weight ~= nil then
    infobox = infobox .. '|-\n| Stack limit:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.maxStack .. '\n'
        weight = itemTable.weight/100
  end
    else
        weight = '0.0'
    end
    section = section .. sectionRow('Weight', weight, nil, 'kg')


    -- stack limit
  -- yield
    if itemTable.maxStack ~= nil then
  if itemTable.yield ~= nil then
        section = section .. sectionRow('Stack limit', itemTable.maxStack)
    infobox = infobox .. '|-\n| Improve Gathering: \n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.yield .. '\n'
    end
  end


    -- yield
  -- fuel
    if itemTable.yield ~= nil then
  if itemTable.fuel ~= nil then
        section = section .. sectionRow('Improve Gathering', itemTable.yield)
    infobox = infobox .. '|-\n| Fuel energy:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.fuel .. ' J\n'
    end
  end


    -- fuel
  -- currency
    if itemTable.fuel ~= nil then
  if itemTable.currency ~= nil then
        section = section .. sectionRow('Fuel energy', itemTable.fuel, nil, 'J')
    infobox = infobox .. '|-\n| Used as Currency:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.currency .. '\n'
    end
  end
  return section
end


    -- currency
function sectionHeader(title, count)
    if itemTable.currency ~= nil then
  return [[|- style="background-color: #4688C0; text-align: center;"\n| colspan="2" | \'\'\']] .. L.t(title, count) .. [[\'\'\'\n]]
        section = section .. "|- style=\"text-align: center;\"\n| colspan=\"2\" | " .. L.t('Can back a currency') .. "\n"
    end
    return section
end
end


function IDsSection(itemTable)
function IDsSection(itemTable)
    -- 'IDs' section header
  -- 'IDs' section header
    section = sectionHeader('ID', 2)
  section = sectionHeader('ID', 2)
 
  -- item id (type)
  section = section .. '|- valign=\"center\"\n| Item ID:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.type .. '\n'


    -- item id (type)
  -- id number (type id)
    section = section .. sectionRow('Item ID', itemTable.type)
  section = section .. '|- valign=\"center\"\n| ID Number:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.typeID .. '\n'


    return section
  return section
end
end


function tagSection(itemTable, itemData)
function tagSection(itemTable, itemData)
    -- Tags Header
  -- Tags Header
    local tags = itemTable.tagGroups
  local tags = itemTable.tagGroups
    section = sectionHeader('Tag', Utils.tableLen(tags))
  section = sectionHeader('Tag', Utils.tableLen(tags))
    local list = ''
  local list = ''
    -- for each item in the list (a is position, b is value)
  -- for each item in the list (a is position, b is value)          
    for a, b in ipairs(tags) do
  for a,b in ipairs(tags) do
        --if not these tags listed here
    --if not these tags listed here
        if (b ~= L.t('Object') or b ~= L.t('World  Object') or b ~= L.t('Housing  Object')) then
    if (b ~=L.t('Object') or b ~= L.t('World  Object') or b ~= L.t('Housing  Object')) then
            -- add the tag to the list
      -- add the tag to the list
            -- HACK: Some tag localisations have spaces in the tag name, but not in the tag data
      -- HACK: Some tag localisations have spaces in the tag name, but not in the tag data
            local tagLink
      local tagLink
            -- Some tags have multiple spaces? Possible data quality issue
      -- Some tags have multiple spaces? Possible data quality issue
            bClean = b:gsub("%s+", " ")
      bClean = b:gsub("%s+", " ")
            if itemData.tags[bClean] ~= nil then
      if itemData.tags[bClean] ~= nil then
                tagLink = L.t('%s Tag'):format(bClean)
        tagLink = bClean .. L.t('Tag')
            else
      else
                tagLink = L.t('%s Tag'):format(bClean:gsub(' ', ''))
        tagLink = bClean:gsub(' ', '') .. L.t('Tag')
            end
      end


            list = list .. '[[' .. tagLink .. '|' .. bClean .. ']][[Category:' .. bClean .. ']]'
      list = list .. '[[' .. tagLink ..'|' .. bClean ..']][[Category:' .. bClean .. ']]'
        end
    end
        -- if not the last item in the list
    -- if not the last item in the list
        if (b ~= tags[#tags]) then
    if (b ~= tags[#tags]) then
            -- add a comma
      -- add a comma
            list = list .. ', '
      list = list .. ', '
        end
     end
     end
    -- Now the list is made add it to the infobox
  end
    section = section .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. list .. '\n'
  -- Now the list is made add it to the infobox
  section = section .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. list .. '\n'


    return section
  return section
end
end


function placementSection(itemTable, itemImageName)
function placementSection(itemTable, itemImageName)
    section = sectionHeader('World Object')
  section = sectionHeader('World Object')
    -- Object Placed Image
-- Object Placed Image
    section = section .. sectionImage(itemImageName, 'Placed')
  local image = checkImage(itemImageName, 'Placed')
  section = section .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'


    -- 'Placement' section
  -- 'Placement' section
    --Placement Header
  --Placement Header
    section = section .. sectionHeader('Placement')
  section = section .. sectionHeader('Placement')


    --Vechile
  --Vechile
    if itemTable.mobile ~= nil then
  if itemTable.mobile ~= nil then
        section = section .. sectionRow('Vehicle/Mobile Object', itemTable.mobile)
    section = section .. '|-\n| Vehicle/Mobile Object:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.mobile .. '\n'
    end
  end


    --Dimensions
  --Dimensions  
    if itemTable.footprint ~= nil then
  if itemTable.footprint ~= nil then
        section = section .. sectionRow('Dimensions (X,Y,Z)', itemTable.footprint)
    section = section .. '|-\n| Dimensions (X,Y,Z):\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.footprint .. '\n'
    end
  end


    --Material Tier
  --Material Tier
    if itemTable.materialTier ~= nil or itemTable.materialTier == 0 then
  if itemTable.materialTier ~= nil or itemTable.materialTier == 0 then
        section = section .. sectionRow('Room Material', itemTable.materialTier) .. '[[Category:Tier ' .. itemTable.materialTier .. ']]\n'
    section = section .. '|-\n| Room Material:\n| style=\"text-align: right; padding: 3px;\" | Tier ' .. itemTable.materialTier .. '[[Category:Tier '.. itemTable.materialTier ..']]\n'
    end
  end


    --Room Req.
  --Room Req.
    if itemTable.roomContainReq ~= nil then
  if itemTable.roomContainReq ~= nil then
        section = section .. sectionRow('Room Required', itemTable.roomContainReq)
    section = section .. '|-\n| Room Required:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomContainReq .. '\n'
    end
  end


    --Room Size. Req.
  --Room Size. Req.
    if itemTable.roomSizeReq ~= nil then
  if itemTable.roomSizeReq ~= nil then
        section = section .. sectionRow('Room Size', itemTable.roomSizeReq, nil, 'm³')
    section = section .. '|-\n| Room Size:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomSizeReq .. ' m³\n'
    end
  end


    --Room Mat. Req.
  --Room Mat. Req.
    if itemTable.roomMatReq ~= nil then
  if itemTable.roomMatReq ~= nil then
        section = section .. sectionRow('Room Materials', itemTable.roomMatReq)
    section = section .. '|-\n| Room Materials:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomMatReq .. '\n'
    end
  end
    return section
  return section
end
end


function objectFormSection(itemTable, itemImageName)
function objectFormSection(itemTable, itemImageName)
    return sectionImage(itemImageName, 'Form')
  local image = checkImage(itemImageName, '_Form')
  return '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
end
end


function housingSection(itemTable)
function housingSection(itemTable)
    -- Housing Header
-- Housing Header
    section = sectionHeader('Housing')
  section = sectionHeader('Housing')


    --roomCategory
  --roomCategory
    section = section .. sectionRow('Room Category', itemTable.roomCategory) .. '[[Category:' .. itemTable.roomCategory .. ']]\n'
  section = section .. '|-\n| Room Category:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomCategory .. '[[Category:' .. itemTable.roomCategory .. ']]\n'


    if itemTable.roomCategory ~= L.t('Industrial') then
  if section.roomCategory ~= 'Industrial' then
        if itemTable.furnitureType ~= nil then
    if section.furnitureType ~= nil then  
            --furnitureType
      --furnitureType
            section = section .. sectionRow('Furniture Type', itemTable.furnitureType) .. '[[Category:' .. itemTable.furnitureType .. ']]\n'
      section = section .. '|-\n| Furniture Type:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.furnitureType .. '[[Category:' .. itemTable.furnitureType .. ']]\n'


            --Value of the object
      --Value of the object
            section = section .. sectionRow('Value', itemTable.skillValue)
      section = section .. '|-\n| Value:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.skillValue .. '\n'


            --Dim. Return % of Object
      --Dim. Return % of Object
            section = section .. sectionRow('Dim. Return %', itemTable.repeatsDepreciation * 100, nil, '%')
      section = section .. '|-\n| Dim. Return %:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.repeatsDepreciation .. '\n'  
        end
     end
     end
  end


    if itemTable.roomCategory == L.t('Industrial') then
  if itemTable.roomCategory == 'Industrial' then
        section = section .. "|- style=\"background-color: #red; text-align: center;\"\n| colspan=\"2\" | '''" .. L.t('ALL ROOM VALUE LOST') .. "'''\n"
    section = section .. '|- style=\"background-color: red; text-align: center;\"\n| colspan=\"2\" | \'\'\'ALL ROOM VALUE LOST\'\'\'\n'
    end
  end


    return section
  return section
end
end


function storageSection(itemTable)
function storageSection(itemTable)
    -- Storage Header
  -- Storage Header
    section = sectionHeader('Storage')
  section = sectionHeader('Storage')


    --Inventory Slots
  --Inventory Slots
    section = section .. sectionRow('Inventory Slots', itemTable.inventorySlots)
  section = section .. '|-\n| Inventory Slots:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.inventorySlots .. '\n'


    --inventoryMaxWeight
  --inventoryMaxWeight
    if itemTable.inventoryMaxWeight ~= nil then
  if itemTable.inventoryMaxWeight ~= nil then
        maxWeightKg = itemTable.inventoryMaxWeight / 1000
    maxWeightKg = itemTable.inventoryMaxWeight/1000
        section = section .. sectionRow('Inventory Max Weight', maxWeightKg, nil, 'kg')
    section = section .. '|-\n| Inventory Max Weight:\n| style=\"text-align: right; padding: 3px;\" | ' .. maxWeightKg .. ' Kg\n'
    else
  else
        section = section .. sectionRow('Inventory Max Weight', L.t('Unlimited'))
    section = section .. '|-\n| Inventory Max Weight:\n| style=\"text-align: right; padding: 3px;\" | Unlimited \n'
    end
  end


    return section
  return section
end
end


function powerSection(itemTable)
function powerSection(itemTable)
    -- Power Header
  -- Power Header
    section = sectionHeader('Power')
  section = sectionHeader('Power')


    --EngergyType
  --EngergyType  
    section = section .. sectionRow('Energy Type', itemTable.energyType) .. '[[Category:' .. itemTable.energyType .. ']]\n'
  section = section .. '|-\n| Energy Type:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyType .. '[[Category:' .. itemTable.energyType .. ']]\n'


    --Grid Radius
  --Grid Radius
    section = section .. sectionRow('Grid Radius', itemTable.gridRadius, nil, 'm')
  section = section .. '|-\n| Grid Radius:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.gridRadius .. ' m\n'


    --Energy Produced
  --Energy Produced
    section = section .. sectionRow('Energy Produced', itemTable.energyProduced, nil, 'w')
  section = section .. '|-\n| Energy Produced:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyProduced .. 'W\n'


    --Energy Used
  --Energy Used
    section = section .. sectionRow('Energy Used', itemTable.energyUsed, nil, 'w')
  section = section .. '|-\n| Energy Used:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyUsed .. 'W\n'


    return section
  return section
end
end


function fuelsSection(itemTable)
function fuelsSection(itemTable)
    -- Fuel Header
  -- Fuel Header
    section = sectionHeader('Fuel')
  section = sectionHeader('Fuel')


    --Fuels Used by Object
  --Fuels Used by Object
    section = section .. sectionRow('Fuels Used', '[[' .. L.t('%s Tag'):format(itemTable.fuelsUsed:gsub('[%[%]]+', '')) .. ']]')
  section = section .. '|-\n| Fuels Used:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.fuelsUsed .. '\n'


    return section
  return section
end
end


function fluidsSection(itemTable)
function fluidsSection(itemTable)
    -- Liquid/Gas Header
-- Liquid/Gas Header
    section = sectionHeader('Liquid/Gas')
  section = sectionHeader('Liquid/Gas')


    --Input (fludisUsed)
--Input (fludisUsed)  
  if itemTable.fluidsUsed ~= nil then
    section = section .. '|-\n| Input: \n| style=\"text-align: right; padding: 3px;\" | '
     if itemTable.fluidsUsed ~= nil then
     if itemTable.fluidsUsed ~= nil then
        local list = ''
      for a,b in ipairs(itemTable.fluidsUsed) do
        for a, b in ipairs(itemTable.fluidsUsed) do
        local acceptedType = b[1]
            local acceptedType = b[1]
        local cRateString = string.gsub(b[2], "%s+", "")
            local cRateString = string.gsub(b[2], "%s+", "")
        local consumingRate = tonumber(cRateString)
            local consumingRate = tonumber(cRateString)
        section = section .. acceptedType .. ' at ' .. consumingRate .. ' L'
            list = list .. L.t('%s at %sL'):format(acceptedType, consumingRate)
        if (a ~= #itemTable.fluidsUsed) then
 
          section = section .. ', '
            if (a ~= #itemTable.fluidsUsed) then
                list = list .. ', '
            end
         end
         end
        section = section .. sectionRow('Input', list)
      end
     end
     end
    section = section .. '\n'
  end


    --Output (liquidProduced)
--Output (liquidProduced)
    if itemTable.fluidsProduced ~= nil then
  if itemTable.fluidsProduced ~= nil then
        local list = ''
    section = section .. '|-\n| Output: \n| style=\"text-align: right; padding: 3px;\" | '
        for a, b in ipairs(itemTable.fluidsProduced) do
    for a,b in ipairs(itemTable.fluidsProduced) do
            local producedType = b[1]
      local producedType = b[1]
            local pRateString = string.gsub(b[2], "%s+", "")
      local pRateString = string.gsub(b[2], "%s+", "")
            local producingRate = tonumber(pRateString)
      local producingRate = tonumber(pRateString)
            if (producingRate == 0) then
      if (producingRate == 0) then
                producingRate = 'Rate of Input'
        producingRate = 'Rate of Input'
            end
      end
            list = list .. L.t('%s at %sL'):format(producedType, producingRate)
      section = section .. producedType .. ' at ' .. producingRate .. ' L'
            if (a ~= #itemTable.fluidsProduced) then
      if (a ~= #itemTable.fluidsProduced) then
                list = list .. ', '
        section = section .. ', '
            end
      end
        end
        section = section .. sectionRow('Output', list)
     end
     end
    section = section .. '\n'
  end


    return section
return section
end
end


function roadItemsSection(itemTable, itemImageName)
function roadItemsSection(itemTable, itemImageName)
    section = sectionHeader('Road Object')
  section = sectionHeader('Road Object')


    -- Object Placed Image
  -- Object Placed Image
    section = section .. sectionImage(itemImageName, 'Placed')
  local image = checkImage(itemImageName, 'Placed')
    return section
  section = section .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
  return section
end
end


function checkImage(imageName, suffix)
function checkImage(imageName, suffix)
    local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. imageName .. '_' .. suffix .. '.png|[[Category:Pages_with_missing_' .. suffix:lower() .. ']]'
  local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. imageName .. '_'..suffix..'.png|[[Category:Pages_with_missing_'..suffix:lower()..']]'
    if mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.png').file.exists then
  if mw.title.makeTitle('File', imageName .. '_'..suffix..'.png').file.exists then
        image = imageName .. '_' .. suffix .. '.png'
    image = imageName .. '_'..suffix..'.png'
    elseif mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.jpg').file.exists then
  elseif mw.title.makeTitle('File', imageName .. '_'..suffix..'.jpg').file.exists then
        image = imageName .. '_' .. suffix .. '.jpg'
    image = imageName .. '_'..suffix..'.jpg'
    end
  end
    return image
  return image
end
end


-- Main entry point for the Module
-- Main entry point for the Module
function p.ItemMain(frame)
function p.ItemMain(frame)
    -- get args from the Template
  -- get args from the Template
    local args = Utils.normaliseArgs(frame)
  local args = Utils.normaliseArgs(frame)


    -- get item data
  -- get item data
    local itemData = mw.loadData("Module:ItemData")
  local itemData = mw.loadData( "Module:ItemData" )
    return itemBox(args, itemData)
  return itemBox( args, itemData )
end
end


return p
return p
Please note that all contributions to Eco - English Wiki are considered to be released under the CC BY-NC-SA 4.0 (see Eco:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following hCaptcha:

Cancel Editing help (opens in new window)

Template used on this page: