ATTENTION! The process of updating WiKi to version Eco 10.x has begun. Those wishing to participate can find out more Information on our ECO Contribution Wiki Discord.
From April 26 to May 12, errors may occur in the Wiki, as we will be carrying out a major update to the information processing modules.

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 3: Line 3:
local p = {}
local p = {}
local Utils = require('Module:Utils')
local Utils = require('Module:Utils')
local L = require('Module:Localization')


-- 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 itemTable = itemData.items[item]


    local item = args.name
if itemTable == nil then
    local itemTable = itemData.items[item]
return item .. ' could not be found in Module:ItemData.'
 
end
    if itemTable == nil then
        return item .. ' could not be found in Module:ItemData. [[Category:MissingItem]]'
    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'
    if itemTable.group == L.t('Food') then
-- Items:Food Icon Image
        text_colour = '#85D66B'
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Icon.png|[[Category:Pages_with_missing_icon]]'
    elseif itemTable.group == L.t('Skill Books') or itemTable.group == L.t('Skill Scrolls') then
if mw.title.makeTitle('File', itemimagename .. '_Icon.png').file.exists then
        text_colour = '#FFCF4D'
image = itemimagename .. '_Icon.png'
    elseif itemTable.group == L.t('Skill Scrolls') then
elseif mw.title.makeTitle('File', itemimagename .. '_Icon.jpg').file.exists then
        text_colour = '#FFCF4D'
image = itemimagename .. '_Icon.jpg'
    end
end
 
    infobox = infobox .. text_colour .. ';\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
    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'
    local icon = Utils.build_icon(item)
    infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | '..icon .. '\n'
elseif itemTable.group == 'Skill Books' then
 
infobox = infobox .. '#FFCF4D;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
    -- 'Description' section header
-- Items:Skill Book Icon Image
    infobox = infobox .. sectionHeader('Description')
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'
 
    if itemTable.description == nil or itemTable.description == '' then
elseif itemTable.group == 'Skill Scrolls' then
        infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'' .. L.t('None') .. '\'\'\'\n'
infobox = infobox .. '#FFCF4D;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
    else
-- Items:Skill Scrolls Icon Image
        infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. itemTable.description .. '\n'
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'
    end
 
else
    --Crafting
infobox = infobox .. '#78B1FF;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
    local craftingRecipes = mw.loadData("Module:CraftingRecipes")
-- Items: Other Icon Image
 
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Icon.png|[[Category:Pages_with_missing_icon]]'
    infobox = infobox .. generalSection(item, itemTable, craftingRecipes, args)
if mw.title.makeTitle('File', itemimagename .. '_Icon.png').file.exists then
 
image = itemimagename .. '_Icon.png'
    infobox = infobox .. IDsSection(itemTable)
elseif mw.title.makeTitle('File', itemimagename .. '_Icon.jpg').file.exists then
 
image = itemimagename .. '_Icon.jpg'
    -- Tags Header
end
    if itemTable.tagGroups ~= nil and itemTable.tagGroups ~= {} then
    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'
        infobox = infobox .. tagSection(itemTable, itemData)
end
    end
      
 
  -- 'Description' section header
    -- 'Item' World Object header (if itemTable.group = Placeable or Blocks)
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n'
    if itemTable.group == L.t('Block Items') or itemTable.group == L.t('World Object Items') then
        infobox = infobox .. placementSection(itemTable, itemimagename)
if itemTable.description == nil then
 
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
        -- Object Form Image
elseif itemTable.description == '' then
        if itemTable.group == L.t('Block Items') then
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
            infobox = infobox .. objectFormSection(itemTable, itemimagename)
else
        end
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. itemTable.description .. '\n'
 
end
        -- 'Housing' section (if there is a Room Category)
        if itemTable.roomCategory ~= nil then
            infobox = infobox .. housingSection(itemTable)
        end
 
        -- 'Storage' Section (if inventorySlots is not nil)
        if itemTable.inventorySlots ~= nil then
            infobox = infobox .. storageSection(itemTable)
        end
 
        -- 'Power' section (if EngeryType is ``not nil)
        if itemTable.energyType ~= nil then
            infobox = infobox .. powerSection(itemTable)
 
        end
 
        -- 'Fuel' Section (if fuelsUsed by Object)
        if itemTable.fuelsUsed ~= nil then
            infobox = infobox .. fuelsSection(itemTable)
        end
 
        -- 'Fluid' section (if fludisUsed is not nil)
        if itemTable.fluidsUsed ~= nil or itemTable.fluidsProduced ~= nil then
            infobox = infobox .. fluidsSection(itemTable)
        end
     end
 
    -- Road Object header (if group == Road Items)
    if itemTable.group == L.t('Road Items') then
        infobox = infobox .. roadItemsSection(itemTable, itemimagename)
    end
    infobox = infobox .. '|}'
    return infobox
end
 
function sectionHeader(title, count)
    return "|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | '''" .. L.t(title, count) .. "'''\n"
end
 
function sectionRow(label, content, count, unit)
    if unit ~= nil then
        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
 
function sectionImage(imageName, suffix)
    local image = checkImage(imageName, suffix)
    return '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
end
 
local function addToSet(set, key)
    set[key] = true
end
 
local function setNotContains(set, key)
    return set[key] == nil
end
 
local function craftingSubSection(title, item, productsOrIngredients, recipes)
    local stations = {}
    local sortStations = {}
    local stationString = ''
    for _, recipeName in ipairs(productsOrIngredients[item]) do
        local currentRecipe = recipes[recipeName]
        if currentRecipe ~= nil then
            if currentRecipe.variants[recipeName] ~= nil then
                local currentStation = currentRecipe.craftStn[1][1]
                if setNotContains(stations, currentStation) then
                    addToSet(stations, currentStation)
                end
            end
        end
    end
 
    if stations then
        for a, _ in pairs(stations) do
            table.insert(sortStations, a)
        end
        table.sort(sortStations)
        for i, n in ipairs(sortStations) do
            stationString = stationString .. ' [[' .. n .. ']]'
            if (n ~= sortStations[#sortStations]) then
                -- add a comma
                stationString = stationString .. ', '
            end
        end
        return sectionRow(title, stationString)
    else
        return sectionRow(title, L.t('N/A'))
    end
end
 
function generalSection(item, itemTable, craftingRecipes, args)
     -- 'General' section header
     -- 'General' section header
    section = sectionHeader('General')
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'General\'\'\'\n'
 
   
    -- Is a product at these tables
--Crafting
    if craftingRecipes.products[item] ~= nil and Utils.tableLen(craftingRecipes.products[item]) >= 1 then
local craftingRecipes = require( "Module:CraftingRecipes" )
        section = section .. craftingSubSection('Created at', item, craftingRecipes.products, craftingRecipes.recipes)
local recipes = craftingRecipes.recipes
    end
 
local function addToSet(set, key)
    -- Is an ingredient at these tables
set[key] = true
    if craftingRecipes.ingredients[item] ~= nil and Utils.tableLen(craftingRecipes.ingredients[item]) >= 1 then
end
        section = section .. craftingSubSection('Used at', item, craftingRecipes.ingredients, craftingRecipes.recipes)
    end
local function setNotContains(set, key)
 
return set[key] == nil
    -- calories and nutrients (if itemTable.group == 'Food')
end
    if itemTable.group == L.t('Food') then
        section = section .. sectionRow('Calorie', itemTable.calories, tonumber(itemTable.calories), 'cal')
-- Is a product at these tables
        section = section .. '|- valign=\"center\"\n| rowspan=\"4\" | ' .. L.t('Nutrients') .. ':\n'
if craftingRecipes.products[item] ~= nil and #craftingRecipes.products[item] >= 1 then
        section = section .. '| style=\"color: red; text-align: right; padding: 3px;\" | ' .. L.t('Carbs') .. ': ' .. itemTable.carbs .. '\n'
local count = 0
        section = section .. '|- valign=\"center\"\n| style=\"color: orange; text-align: right; padding: 3px;\" | ' .. L.t('Protein') .. ': ' .. itemTable.protein .. '\n'
local stations = {}
        section = section .. '|- valign=\"center\"\n| style=\"color: darkkhaki; text-align: right; padding: 3px;\" | ' .. L.t('Fat') .. ': ' .. itemTable.fat .. '\n'
local sortStations = {}
        section = section .. '|- valign=\"center\"\n| style=\"color: limegreen; text-align: right; padding: 3px;\" | ' .. L.t('Vitamins') .. ': ' .. itemTable.vitamins .. '\n'
local stationString = ''
        section = section .. sectionRow('Nutrition Density', L.t('%s per 100 cals'):format(itemTable.density))
local found = false
    end
for k, v in ipairs( craftingRecipes.products[item] ) do
 
if recipes[v] ~= nil then
    -- carried
for num = 1, #recipes[v].numberOfVariants do
    local carried
if (recipes[v].variants[v] ~= nil and recipes[v].numberOfVariants <= tostring(1)) then
    if args.carried ~= nil and args.carried ~= '' then
if setNotContains(stations, recipes[v].craftStn[1][1]) then
        carried = args.carried
addToSet(stations, recipes[v].craftStn[1][1])
    else
count = count + 1
        carried = itemTable.carried
end
    end
if found == false then
    section = section .. sectionRow('Carried in', carried)
found = true
 
infobox = infobox .. '|-\n| Created At:\n| style=\"text-align: right; padding: 3px;\" |'
     -- weight
end
    local weight
end
    if itemTable.weight ~= nil then
end
        weight = itemTable.weight/100
end
    else
end
        weight = '0.0'
    end
local track = 0
     section = section .. sectionRow('Weight', weight, nil, 'kg')
 
if found == true then
    -- stack limit
for a, b in pairs(stations) do
    if itemTable.maxStack ~= nil then
table.insert(sortStations, a)
        section = section .. sectionRow('Stack limit', itemTable.maxStack)
end
    end
table.sort(sortStations)
 
for i, n in ipairs(sortStations) do
    -- yield
stationString = stationString .. ' [[' .. n .. ']]'
    if itemTable.yield ~= nil then
track = track + 1
        section = section .. sectionRow('Improve Gathering', itemTable.yield)
if track ~= count then -- Changed these line to produce comma if not last table.
    end
stationString = stationString .. ','
 
end
    -- fuel
end
    if itemTable.fuel ~= nil then
infobox = infobox .. stationString .. '\n'
        section = section .. sectionRow('Fuel energy', itemTable.fuel, nil, 'J')
else
    end
infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right; padding: 3px;\" | N/A\n'
 
end
    -- currency
end
    if itemTable.currency ~= nil then
        section = section .. "|- style=\"text-align: center;\"\n| colspan=\"2\" | " .. L.t('Can back a currency') .. "\n"
-- Is an ingredient at these tables
    end
if craftingRecipes.ingredients[item] ~= nil and #craftingRecipes.ingredients[item] >= 1 then
    return section
local count = 0
end
local stations = {}
 
local sortStations = {}
function IDsSection(itemTable)
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
local track = 0
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
infobox = infobox .. stationString .. '\n'
else
infobox = infobox .. '|-\n| Used at:\n| style=\"text-align: right; padding: 3px;\" | N/A\n'
end
end
-- calories and nutrients (if itemTable.group == 'Food')
if itemTable.group == 'Food' then
infobox = infobox .. '|-\n| Calories:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.calories .. '\n|- valign=\"center\"\n| rowspan=\"4\" | Nutrients:\n'
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
-- carried
if args.carried ~= nil and args.carried ~= '' then
infobox = infobox .. '|-\n| Carried in:\n| style=\"text-align: right; padding: 3px;\" | ' .. args.carried .. '\n'
else
infobox = infobox .. '|-\n| Carried in:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.carried .. '\n'
end
      
-- weight
if itemTable.weight ~= nil then
infobox = infobox .. '|-\n| Weight:\n| style="text-align: right; padding: 3px;" | ' .. itemTable.weight .. ' kg\n'
else
infobox = infobox .. '|-\n| Weight:\n| style="text-align: right; padding: 3px;" | 0.00kg\n'
end
      
-- stack limit
if itemTable.maxStack ~= nil then
infobox = infobox .. '|-\n| Stack limit:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.maxStack .. '\n'
end
-- yield  
if itemTable.yield ~= nil then
infobox = infobox .. '|-\n| Improve Gathering: \n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.yield .. '\n'
end
-- fuel
if itemTable.fuel ~= nil then
infobox = infobox .. '|-\n| Fuel energy:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.fuel .. ' J\n'
end
   
-- currency
if itemTable.currency ~= nil then
infobox = infobox .. '|-\n| Used as Currency:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.currency .. '\n'
end
     -- 'IDs' section header
     -- 'IDs' section header
     section = sectionHeader('ID', 2)
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'IDs\'\'\'\n'
      
-- item id (type)
infobox = infobox .. '|- valign=\"center\"\n| Item ID:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.type .. '\n'
   
-- id number (type id)
infobox = infobox .. '|- valign=\"center\"\n| ID Number:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.typeID .. '\n'


    -- item id (type)
-- Tags Header
    section = section .. sectionRow('Item ID', itemTable.type)
if itemTable.tagGroups ~= nil and itemTable.tagGroups ~= {} then
            -- Tags Header
            infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Tags\'\'\'\n'
            local tags = itemTable.tagGroups
            local list = ''
            -- for each item in the list (a is position, b is value)          
            for a,b in ipairs(tags) do
            --if not these tags listed here
                if (b ~='Object' or b ~= 'World  Object' or b ~= 'Housing  Object') then
                    -- add the tag to the list
                    -- HACK: Some tag localisations have spaces in the tag name, but not in the tag data
                    local tagLink
                    -- Some tags have multiple spaces? Possible data quality issue
                    bClean = b:gsub("%s+", " ")
                    if itemData.tags[bClean] ~= nil then
                        tagLink = bClean .. 'Tag'
                    else
                        tagLink = bClean:gsub(' ', '') .. 'Tag'
                    end


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


     return section
     -- 'Item' World Object header (if itemTable.group = Placeable or Blocks)
end
if itemTable.group == 'Block Items' or itemTable.group == 'World Object Items' then
 
infobox = infobox .. '|- style=\"text-align: center; background-color: #517ab2;\"\n| colspan=\"2\" | \'\'\'World Object\'\'\'\n'
function placementSection(itemTable, itemImageName)
    section = sectionHeader('World Object')
-- Object Placed Image
    -- Object Placed Image
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Placed.png|[[Category:Pages_with_missing_placed]]'
    section = section .. sectionImage(itemImageName, 'Placed')
if mw.title.makeTitle('File', itemimagename .. '_Placed.png').file.exists then
 
image = itemimagename .. '_Placed.png'
    -- 'Placement' section
elseif mw.title.makeTitle('File', itemimagename .. '_Placed.jpg').file.exists then
    --Placement Header
image = itemimagename .. '_Placed.jpg'
    section = section .. sectionHeader('Placement')
end
 
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
    --Vechile
 
    if itemTable.mobile ~= nil then
-- 'Placement' section
        section = section .. sectionRow('Vehicle/Mobile Object', itemTable.mobile)
--Placement Header
    end
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Placement\'\'\'\n'
 
    --Dimensions
    if itemTable.footprint ~= nil then
        section = section .. sectionRow('Dimensions (X,Y,Z)', itemTable.footprint)
    end
 
    --Material Tier
    if itemTable.materialTier ~= nil or itemTable.materialTier == 0 then
        section = section .. sectionRow('Room Material', itemTable.materialTier) .. '[[Category:Tier ' .. itemTable.materialTier .. ']]\n'
    end
 
    --Room Req.
    if itemTable.roomContainReq ~= nil then
        section = section .. sectionRow('Room Required', itemTable.roomContainReq)
    end
 
    --Room Size. Req.
    if itemTable.roomSizeReq ~= nil then
        section = section .. sectionRow('Room Size', itemTable.roomSizeReq, nil, '')
    end
 
    --Room Mat. Req.
    if itemTable.roomMatReq ~= nil then
        section = section .. sectionRow('Room Materials', itemTable.roomMatReq)
    end
    return section
end
 
function objectFormSection(itemTable, itemImageName)
    return sectionImage(itemImageName, 'Form')
end


function housingSection(itemTable)
--Vechile
    -- Housing Header
if itemTable.mobile ~= nil then
    section = sectionHeader('Housing')
infobox = infobox .. '|-\n| Vehicle/Mobile Object:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.mobile .. '\n'
end
--Dimensions
if itemTable.footprint ~= nil then
infobox = infobox .. '|-\n| Dimensions (X,Y,Z):\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.footprint .. '\n'
end
--Material Tier
if itemTable.materialTier ~= nil or itemTable.materialTier == 0 then
infobox = infobox .. '|-\n| Room Material:\n| style=\"text-align: right; padding: 3px;\" | Tier ' .. itemTable.materialTier .. '[[Category:Tier '.. itemTable.materialTier ..']]\n'
end
--Room Req.
if itemTable.roomContainReq ~= nil then
infobox = infobox .. '|-\n| Room Required:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomContainReq .. '\n'
end
--Room Size. Req.
if itemTable.roomSizeReq ~= nil then
infobox = infobox .. '|-\n| Room Size:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomSizeReq .. ' m³\n'
end
--Room Mat. Req.
if itemTable.roomMatReq ~= nil then
infobox = infobox .. '|-\n| Room Materials:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomMatReq .. '\n'
end
-- Object Form Image
if itemTable.group == 'Block Items' then
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Form.png|[[Category:Pages_with_missing_form]]'
if mw.title.makeTitle('File', itemimagename .. '_Form.png').file.exists then
image = itemimagename .. '_Form.png'
elseif mw.title.makeTitle('File', itemimagename .. '_Form.jpg').file.exists then
image = itemimagename .. '_Form.jpg'
end
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
end


     --roomCategory
-- 'Housing' section (if there is a Room Category)
    section = section .. sectionRow('Room Category', itemTable.roomCategory) .. '[[Category:' .. itemTable.roomCategory .. ']]\n'
if itemTable.roomCategory ~= nil then 
-- Housing Header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Housing\'\'\'\n'
      
--roomCategory
infobox = infobox .. '|-\n| Room Category:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomCategory .. '[[Catergory:Room '.. itemTable.roomCategory ..'\n'


    if itemTable.roomCategory ~= L.t('Industrial') then
if itemTable.roomCategory ~= 'Industrial' then
        if itemTable.furnitureType ~= nil then
if itemTable.furnitureType ~= nil then  
            --furnitureType
--furnitureType
            section = section .. sectionRow('Furniture Type', itemTable.furnitureType) .. '[[Category:' .. itemTable.furnitureType .. ']]\n'
infobox = infobox .. '|-\n| Furniture Type:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.furnitureType .. '[[Category:Furniture_' .. itemTable.furnitureType .. ']]\n'
           
--Value of the object
infobox = infobox .. '|-\n| Value:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.skillValue .. '\n'
           
--Dim. Return % of Object 
infobox = infobox .. '|-\n| Dim. Return %:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.repeatsDepreciation .. '\n'   
end
end
if itemTable.roomCategory == 'Industrial' then
infobox = infobox .. '|- style=\"background-color: red; text-align: center;\"\n| colspan=\"2\" | \'\'\'ALL ROOM VALUE LOST\'\'\'\n'
end
end
-- 'Storage' Section (if inventorySlots is not nil)
if itemTable.inventorySlots ~= nil then
-- Storage Header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Storage\'\'\'\n'


            --Value of the object
--Inventory Slots
            section = section .. sectionRow('Value', itemTable.skillValue)
infobox = infobox .. '|-\n| Inventory Slots:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.inventorySlots .. '\n'
--inventoryMaxWeight
if itemTable.inventoryMaxWeight ~= nil then
maxWeightKg = itemTable.inventoryMaxWeight/1000
infobox = infobox .. '|-\n| Inventory Max Weight:\n| style=\"text-align: right; padding: 3px;\" | ' .. maxWeightKg .. ' Kg\n'
else
infobox = infobox .. '|-\n| Inventory Max Weight:\n| style=\"text-align: right; padding: 3px;\" | Unlimited \n'
end
end


            --Dim. Return % of Object
-- 'Power' section (if EngeryType is ``not nil)
            section = section .. sectionRow('Dim. Return %', itemTable.repeatsDepreciation * 100, nil, '%')
if itemTable.energyType ~= nil then 
        end
-- Power Header
    end
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Power\'\'\'[[Category:Power]]\n'


    if itemTable.roomCategory == L.t('Industrial') then
--EngergyType
        section = section .. "|- style=\"background-color: #red; text-align: center;\"\n| colspan=\"2\" | '''" .. L.t('ALL ROOM VALUE LOST') .. "'''\n"
infobox = infobox .. '|-\n| Energy Type:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyType .. '[[Category:' .. itemTable.energyType .. ']]\n'
    end
--Grid Radius
infobox = infobox .. '|-\n| Grid Radius:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.gridRadius .. ' m\n'
--Energy Produced
infobox = infobox .. '|-\n| Energy Produced:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyProduced .. ' J\n'
--Energy Used
infobox = infobox .. '|-\n| Energy Used:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyUsed .. ' J\n'
end


    return section
-- 'Fuel' Section (if fuelsUsed by Object)
end
if itemTable.fuelsUsed ~= nil then
 
-- Fuel Header
function storageSection(itemTable)
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Fuel\'\'\'\n'
    -- Storage Header
    section = sectionHeader('Storage')
--Fuels Used by Object
 
infobox = infobox .. '|-\n| Fuels Used:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.fuelsUsed .. '\n'
    --Inventory Slots
end
    section = section .. sectionRow('Inventory Slots', itemTable.inventorySlots)
 
-- 'Fluid' section (if fludisUsed is not nil)  
    --inventoryMaxWeight
            if itemTable.fluidsUsed ~= nil then
    if itemTable.inventoryMaxWeight ~= nil then
            -- Liquid/Gas Header
        maxWeightKg = itemTable.inventoryMaxWeight / 1000
                infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Liquid/Gas\'\'\'\n'
        section = section .. sectionRow('Inventory Max Weight', maxWeightKg, nil, 'kg')
           
    else
                --Input (fludisUsed)  
        section = section .. sectionRow('Inventory Max Weight', L.t('Unlimited'))
                infobox = infobox .. '|-\n| Input: \n| style=\"text-align: right; padding: 3px;\" | '  
    end
                    for a,b in ipairs(itemTable.fluidsUsed) do
 
                        local acceptedType = b[1]
    return section
                        local cRateString = string.gsub(b[2], "%s+", "")
end
                        local consumingRate = tonumber(cRateString)
 
                        infobox = infobox .. acceptedType .. ' at ' .. consumingRate .. ' L'
function powerSection(itemTable)
                        if (a ~= #itemTable.fluidsUsed) then
    -- Power Header
                            infobox = infobox .. ', '
    section = sectionHeader('Power')
                        end
 
                    end
    --EngergyType
                infobox = infobox .. '\n'
    section = section .. sectionRow('Energy Type', itemTable.energyType) .. '[[Category:' .. itemTable.energyType .. ']]\n'
 
--Output (liquidProduced)
    --Grid Radius
infobox = infobox .. '|-\n| Output: \n| style=\"text-align: right; padding: 3px;\" | '  
    section = section .. sectionRow('Grid Radius', itemTable.gridRadius, nil, 'm')
for a,b in ipairs(itemTable.fluidsProduced) do
 
local producedType = b[1]
    --Energy Produced
                        local pRateString = string.gsub(b[2], "%s+", "")
    section = section .. sectionRow('Energy Produced', itemTable.energyProduced, nil, 'w')
                        local producingRate = tonumber(pRateString)
 
if (producingRate == 0) then
    --Energy Used
producingRate = 'Rate of Input'
    section = section .. sectionRow('Energy Used', itemTable.energyUsed, nil, 'w')
end
 
infobox = infobox .. producedType .. ' at ' .. producingRate .. ' L'
    return section
if (a ~= #itemTable.fluidsProduced) then
end
infobox = infobox .. ', '
 
end
function fuelsSection(itemTable)
end
    -- Fuel Header
infobox = infobox .. '\n'
    section = sectionHeader('Fuel')
end
 
end
    --Fuels Used by Object
    section = section .. sectionRow('Fuels Used', '[[' .. L.t('%s Tag'):format(itemTable.fuelsUsed:gsub('[%[%]]+', '')) .. ']]')
-- Road Object header (if group == Road Items)
 
if itemTable.group == 'Road Items' then
    return section
infobox = infobox .. '|- style=\"text-align: center; background-color: #517ab2;\"\n| colspan=\"2\" | \'\'\'Road Object\'\'\'\n'
end
 
-- Object Placed Image
function fluidsSection(itemTable)
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Placed.png|[[Category:Pages_with_missing_placed]]'
    -- Liquid/Gas Header
if mw.title.makeTitle('File', itemimagename .. '_Placed.png').file.exists then
    section = sectionHeader('Liquid/Gas')
image = itemimagename .. '_Placed.png'
 
elseif mw.title.makeTitle('File', itemimagename .. '_Placed.jpg').file.exists then
    --Input (fludisUsed)
image = itemimagename .. '_Placed.jpg'
    if itemTable.fluidsUsed ~= nil then
end
        local list = ''
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
        for a, b in ipairs(itemTable.fluidsUsed) do
end
            local acceptedType = b[1]
            local cRateString = string.gsub(b[2], "%s+", "")
infobox = infobox .. '|}'
            local consumingRate = tonumber(cRateString)
return infobox
            list = list .. L.t('%s at %sL'):format(acceptedType, consumingRate)
end
 
            if (a ~= #itemTable.fluidsUsed) then
                list = list .. ', '
            end
        end
        section = section .. sectionRow('Input', list)
    end
 
    --Output (liquidProduced)
    if itemTable.fluidsProduced ~= nil then
        local list = ''
        for a, b in ipairs(itemTable.fluidsProduced) do
            local producedType = b[1]
            local pRateString = string.gsub(b[2], "%s+", "")
            local producingRate = tonumber(pRateString)
            if (producingRate == 0) then
                producingRate = 'Rate of Input'
            end
            list = list .. L.t('%s at %sL'):format(producedType, producingRate)
            if (a ~= #itemTable.fluidsProduced) then
                list = list .. ', '
            end
        end
        section = section .. sectionRow('Output', list)
    end
 
    return section
end
 
function roadItemsSection(itemTable, itemImageName)
    section = sectionHeader('Road Object')
 
    -- Object Placed Image
    section = section .. sectionImage(itemImageName, 'Placed')
    return section
end
 
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() .. ']]'
    if mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.png').file.exists then
        image = imageName .. '_' .. suffix .. '.png'
    elseif mw.title.makeTitle('File', imageName .. '_' .. suffix .. '.jpg').file.exists then
        image = imageName .. '_' .. suffix .. '.jpg'
    end
    return image
end


-- Main entry point for the Module
-- Main entry point for the Module
Line 466: Line 452:
     -- 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 = require( "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: