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 1: Line 1:
-- Credit: Original Infobox (now known as Infobox_Item) created by Pradoxzon was then edited by Nesphit and TreeNuts0. Fyre (FishAus) and Scotty (ZeelNightwolf) further edited the Infobox_Item. They then duplicated and used as a base for Infobox_Skill, Infobox_Plant, and Infobox_Animal.
local p = {}


local p = {}
-- Grabs args from the parent frame
local Utils = require('Module:Utils')
-- Trims and parses the args into a table, then returns the table
local L = require('Module:Localization')
function norm()
    local origArgs = mw.getCurrentFrame():getParent().args
    local args = {}
   
    for k, v in pairs( origArgs ) do
        v = mw.text.trim( tostring( v ) )
        if v ~= '' then
            args[k] = v
        end
    end
   
    return args
end


-- 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 itemimagename = string.gsub(item, ' ', '')
    if itemTable == nil then
       
        return item .. ' could not be found in Module:ItemData. [[Category:MissingItem]]'
local itemTable = itemData.items[item]
    end
if itemTable == nil then
 
return item .. ' could not be found in Module:ItemData.'
    local itemType = itemTable.type
end
    local itemEN = string.sub(itemType, 1, -5)
      
     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 of the item
infobox = infobox .. '|- style=\"color: white; background-color: darkred; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. item .. '</big>\'\'\'\n'
   
-- the item's type (ItemData - group)
infobox = infobox .. '|- style=\"text-align: center; color: white; background-color: '
if itemTable.group == 'Food' then
infobox = infobox .. '#4b9130;\"\n| colspan=\"2\" | \'\'\'Food\'\'\'\n'
elseif itemTable.group == 'Skill Books' or itemTable.group == 'Skill Scrolls' then
infobox = infobox .. '#af8d33;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
else
infobox = infobox .. '#517ab2;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
end
-- Tag/Category Section
if itemTable.tagGroups ~= {} then
-- Tag Header
infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.tagGroups .. '\'\'\'\n'
end


    -- 'Name and Image' section
    -- name of the item
-- Items Icon Image
    infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. item .. '</big>\'\'\'\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
    -- the item's type (ItemData - group)
image = itemimagename .. '_Icon.png'
    infobox = infobox .. '|- style=\"text-align: center; color: white; background-color: '
elseif mw.title.makeTitle('File', itemimagename .. '_Icon.jpg').file.exists then
 
image = itemimagename .. '_Icon.jpg'
    local text_colour = '#78B1FF'
end
 
      
    if itemTable.group == L.t('Food') then
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|frameless|95px]]\n'
        text_colour = '#85D66B'
   
    elseif itemTable.group == L.t('Skill Books') or itemTable.group == L.t('Skill Scrolls') then
  -- 'Description' section header
        text_colour = '#FFCF4D'
infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n'
    elseif itemTable.group == L.t('Skill Scrolls') then
        text_colour = '#FFCF4D'
if itemTable.description == nil then
    end
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
 
elseif itemTable.description == '' then
    infobox = infobox .. text_colour .. ';\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
     local icon = Utils.checkImage(itemTable.type)
else
    infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | '..icon .. '\n'
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. itemTable.description .. '\n'
 
end
    -- 'Description' section header
    infobox = infobox .. sectionHeader('Description')
 
    if itemTable.description == nil or itemTable.description == '' then
        infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'' .. L.t('None') .. '\'\'\'\n'
    else
        infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. itemTable.description .. '\n'
    end
 
    --Crafting
    local craftingRecipes = mw.loadData("Module:CraftingRecipes")
 
    infobox = infobox .. generalSection(item, itemTable, craftingRecipes, args)
 
    infobox = infobox .. IDsSection(itemTable)
 
    -- Tags Header
    if itemTable.tagGroups ~= nil and itemTable.tagGroups ~= {} then
        infobox = infobox .. tagSection(itemTable, itemData)
    end
 
    -- 'Item' World Object header (if itemTable.group = Placeable or Blocks)
    if itemTable.footprint ~= nil then
        infobox = infobox .. placementSection(itemTable, itemimagename)
 
        -- Object Form Image
        if itemTable.group == L.t('Block Items') then
            infobox = infobox .. objectFormSection(itemTable, itemimagename)
        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: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'General\'\'\'\n'
 
   
    -- Is a product at these tables
-- created at
    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')
if craftingRecipes.items[item] ~= nil and #craftingRecipes.items[item] >= 1 then
        section = section .. '|- valign=\"center\"\n| rowspan=\"4\" | ' .. L.t('Nutrients') .. ':\n'
local count = 0
        section = section .. '| style=\"color: red; text-align: right; padding: 3px;\" | ' .. L.t('Carbs') .. ': ' .. itemTable.carbs .. '\n'
local stations = {}
        section = section .. '|- valign=\"center\"\n| style=\"color: orange; text-align: right; padding: 3px;\" | ' .. L.t('Protein') .. ': ' .. itemTable.protein .. '\n'
local sortStations = {}
        section = section .. '|- valign=\"center\"\n| style=\"color: darkkhaki; text-align: right; padding: 3px;\" | ' .. L.t('Fat') .. ': ' .. itemTable.fat .. '\n'
local stationString = ''
        section = section .. '|- valign=\"center\"\n| style=\"color: limegreen; text-align: right; padding: 3px;\" | ' .. L.t('Vitamins') .. ': ' .. itemTable.vitamins .. '\n'
local found = false
        section = section .. sectionRow('Nutrition Density', L.t('%s per 100 cals'):format(itemTable.density))
for k, v in ipairs( craftingRecipes.items[item] ) do
    end
for num = 1, #recipes[v].products do
 
if (recipes[v].products[num][1] ~= nil and recipes[v].products[num][1] == item) then
    -- carried
if setNotContains(stations, recipes[v].craftStn[1]) then
    local carried
addToSet(stations, recipes[v].craftStn[1])
    if args.carried ~= nil and args.carried ~= '' then
count = count + 1
        carried = args.carried
end
    else
if found == false then
        carried = itemTable.carried
found = true
    end
infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right;\" |'
    section = section .. sectionRow('Carried in', carried)
end
 
end
    -- weight
end
    local weight
end
    if itemTable.weight ~= nil then
        weight = itemTable.weight/100
local track = 0
    else
if found == true then
        weight = '0.0'
for a, b in pairs(stations) do
    end
table.insert(sortStations, a)
    section = section .. sectionRow('Weight', weight, nil, 'kg')
end
 
table.sort(sortStations)
    -- stack limit
for i, n in ipairs(sortStations) do
    if itemTable.maxStack ~= nil then
stationString = stationString .. ' [[' .. n .. ']]'
        section = section .. sectionRow('Stack limit', itemTable.maxStack)
track = track + 1
    end
if track ~= count then -- Changed these line to produce comma if not last table.
 
stationString = stationString .. ','
    -- yield
end
    if itemTable.yield ~= nil then
end
        section = section .. sectionRow('Improve Gathering', itemTable.yield)
infobox = infobox .. stationString .. '\n'
    end
else
 
infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right;\" | N/A\n'
    -- fuel
end
    if itemTable.fuel ~= nil then
elseif args.created ~= nil and args.created ~= '' then
        section = section .. sectionRow('Fuel energy', itemTable.fuel, nil, 'J')
infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right;\" | ' .. args.created .. '\n'
    end
else
infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right;\" | N/A\n'
end


    -- currency
-- calories and nutrients (if itemTable.group == 'Food')
    if itemTable.currency ~= nil then
if itemTable.group == 'Food' then
        section = section .. "|- style=\"text-align: center;\"\n| colspan=\"2\" | " .. L.t('Can back a currency') .. "\n"
infobox = infobox .. '|-\n| Calories:\n| style=\"text-align: right;\" | ' .. itemTable.calories .. '\n|- valign=\"center\"\n| rowspan=\"4\" | Nutrients:\n'
     end
infobox = infobox .. '| style=\"color: red; text-align: right;\" | Carbs: ' .. itemTable.carbs .. '\n'
     return section
infobox = infobox .. '|- valign=\"center\"\n| style=\"color: orange; text-align: right;\" | Protein: ' .. itemTable.protein .. '\n'
end
infobox = infobox .. '|- valign=\"center\"\n| style=\"color: yellow; text-align: right;\" | Fat: ' .. itemTable.fat .. '\n'
 
infobox = infobox .. '|- valign=\"center\"\n| style=\"color: limegreen; text-align: right;\" | Vitamins: ' .. itemTable.vitamins .. '\n'
function IDsSection(itemTable)
infobox = infobox .. '|-\n| Nutrition Density:\n| style=\"text-align: right;\" | ' .. 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;\" | ' .. args.carried .. '\n'
else
infobox = infobox .. '|-\n| Carried in:\n| style=\"text-align: right;\" | ' .. itemTable.carried .. '\n'
end
      
-- weight
if itemTable.weight ~= nil then
infobox = infobox .. '|-\n| Weight:\n| style="text-align: right;" | ' .. itemTable.weight .. ' kg\n'
else
infobox = infobox .. '|-\n| Weight:\n| style="text-align: right;" | 0.00kg\n'
end
      
-- stack limit
if itemTable.maxStack ~= nil then
infobox = infobox .. '|-\n| Stack limit:\n| style=\"text-align: right;\" | ' .. itemTable.maxStack .. '\n'
end
-- yield
if itemTable.yield ~= nil then
infobox = infobox .. '|-\n| Improve Gathering: \n| style=\"text-align: right;\" | ' .. itemTable.yield .. '\n'
end
-- fuel
if itemTable.fuel ~= nil then
infobox = infobox .. '|-\n| Fuel energy:\n| style=\"text-align: right;\" | ' .. itemTable.fuel .. ' J\n'
end
   
-- currency
if itemTable.currency ~= nil then
infobox = infobox .. '|-\n| Used as Currency:\n| style=\"text-align: right;\" | ' .. itemTable.currency .. '\n'
end
     -- 'IDs' section header
     -- 'IDs' section header
     section = sectionHeader('ID', 2)
infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'IDs\'\'\'\n'
      
-- item id (type)
infobox = infobox .. '|- valign=\"center\"\n| Item ID:\n| style=\"text-align: right;\" | ' .. itemTable.type .. '\n'
   
-- id number (type id)
infobox = infobox .. '|- valign=\"center\"\n| ID Number:\n| style=\"text-align: right;\" | ' .. itemTable.typeID .. '\n'


     -- item id (type)
     -- 'Item' World Object header (if itemTable.group = Placeable or Blocks)
    section = section .. sectionRow('Item ID', itemTable.type)
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'
-- 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]]'
if mw.title.makeTitle('File', itemimagename .. '_Placed.png').file.exists then
image = itemimagename .. '_Placed.png'
elseif mw.title.makeTitle('File', itemimagename .. '_Placed.jpg').file.exists then
image = itemimagename .. '_Placed.jpg'
end
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
 
-- 'Placement' section
--Placement Header
infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Placement\'\'\'\n'


    return section
--Vechile
end
if itemTable.mobile ~= nil then
infobox = infobox .. '|-\n| Vehicle/Mobile Object:\n| style=\"text-align: right;\" | ' .. itemTable.mobile .. '\n'
end
--Dimensions
if itemTable.footprint ~= nil then
infobox = infobox .. '|-\n| Dimensions (X,Y,Z):\n| style=\"text-align: right;\" | ' .. 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;\" | Tier ' .. itemTable.materialTier .. '\n'
end
--Room Req.
if itemTable.roomContainReq ~= nil then
infobox = infobox .. '|-\n| Room Required:\n| style=\"text-align: right;\" | ' .. itemTable.roomContainReq .. '\n'
end
--Room Size. Req.
if itemTable.roomSizeReq ~= nil then
infobox = infobox .. '|-\n| Room Size:\n| style=\"text-align: right;\" | ' .. itemTable.roomSizeReq .. ' m³\n'
end
--Room Mat. Req.
if itemTable.roomMatReq ~= nil then
infobox = infobox .. '|-\n| Room Materials:\n| style=\"text-align: right;\" | ' .. 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


function tagSection(itemTable, itemData)
-- 'Housing' section (if there is a Room Category)
    -- Tags Header
if itemTable.roomCategory ~= nil then  
    local tags = itemTable.tagGroups
-- Housing Header
    section = sectionHeader('Tag', Utils.tableLen(tags))
infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Housing\'\'\'\n'
    local list = ''
   
    -- for each item in the list (a is position, b is value)
--roomCategory
    for a, b in ipairs(tags) do
infobox = infobox .. '|-\n| Room Category:\n| style=\"text-align: right;\" | ' .. itemTable.roomCategory .. '\n'
        --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


            list = list .. '[[' .. tagLink .. '|' .. bClean .. ']][[Category:' .. bClean .. ']]'
if itemTable.roomCategory ~= 'Industrial' then
        end
if itemTable.furnitureType ~= nil then
        -- if not the last item in the list
--furnitureType
        if (b ~= tags[#tags]) then
infobox = infobox .. '|-\n| Furniture Type:\n| style=\"text-align: right;\" | ' .. itemTable.furnitureType .. '\n'
            -- add a comma
           
            list = list .. ', '
--Value of the object
        end
infobox = infobox .. '|-\n| Value:\n| style=\"text-align: right;\" | ' .. itemTable.skillValue .. '\n'
    end
           
    -- Now the list is made add it to the infobox
--Dim. Return % of Object 
    section = section .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. list .. '\n'
infobox = infobox .. '|-\n| Dim. Return %:\n| style=\"text-align: right;\" | ' .. 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: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Storage\'\'\'\n'


    return section
--Inventory Slots
end
infobox = infobox .. '|-\n| Inventory Slots:\n| style=\"text-align: right;\" | ' .. itemTable.inventorySlots .. '\n'
--inventoryMaxWeight
if itemTable.inventoryMaxWeight ~= nil then
maxWeightKg = itemTable.inventoryMaxWeight/1000
infobox = infobox .. '|-\n| Inventory Max Weight:\n| style=\"text-align: right;\" | ' .. maxWeightKg .. ' Kg\n'
else
infobox = infobox .. '|-\n| Inventory Max Weight:\n| style=\"text-align: right;\" | Unlimited \n'
end
end


function placementSection(itemTable, itemImageName)
-- 'Power' section (if EngeryType is ``not nil)
    section = sectionHeader('World Object')
if itemTable.energyType ~= nil then 
    -- Object Placed Image
-- Power Header
    section = section .. sectionImage(itemImageName, 'Placed')
infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Power\'\'\'\n'


    -- 'Placement' section
--EngergyType
    --Placement Header
infobox = infobox .. '|-\n| Energy Type:\n| style=\"text-align: right;\" | ' .. itemTable.energyType .. '\n'
    section = section .. sectionHeader('Placement')
--Grid Radius
infobox = infobox .. '|-\n| Grid Radius:\n| style=\"text-align: right;\" | ' .. itemTable.gridRadius .. ' m\n'
--Energy Produced
infobox = infobox .. '|-\n| Energy Produced:\n| style=\"text-align: right;\" | ' .. itemTable.energyProduced .. ' J\n'
--Energy Used
infobox = infobox .. '|-\n| Energy Used:\n| style=\"text-align: right;\" | ' .. itemTable.energyUsed .. ' J\n'
end


    --Vechile
-- 'Fuel' Section (if fuelsUsed by Object)
    if itemTable.mobile ~= nil then
if itemTable.fuelsUsed ~= nil then
        section = section .. sectionRow('Vehicle/Mobile Object', itemTable.mobile)
-- Fuel Header
    end
infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Fuel\'\'\'\n'
 
    --Dimensions
--Fuels Used by Object
    if itemTable.footprint ~= nil then
infobox = infobox .. '|-\n| Fuels Used:\n| style=\"text-align: right;\" | ' .. itemTable.fuelsUsed .. '\n'
        section = section .. sectionRow('Dimensions (X,Y,Z)', itemTable.footprint)
end
    end
 
-- 'Fluid' section (if fludisUsed is not nil)  
    --Material Tier
            if itemTable.fluidsUsed ~= nil then  
    if itemTable.materialTier ~= nil or itemTable.materialTier == 0 then
            -- Liquid/Gas Header
        section = section .. sectionRow('Room Material', itemTable.materialTier) .. '[[Category:Tier ' .. itemTable.materialTier .. ']]\n'
                infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Liquid/Gas\'\'\'\n'
    end
           
 
                --Input (fludisUsed)  
    --Room Req.
                infobox = infobox .. '|-\n| Input: \n| style=\"text-align: right;\" | '  
    if itemTable.roomContainReq ~= nil then
                    for a,b in ipairs(itemTable.fluidsUsed) do
        section = section .. sectionRow('Room Required', itemTable.roomContainReq)
                        local acceptedType = b[1]
    end
                        local cRateString = string.gsub(b[2], "%s+", "")
 
                        local consumingRate = tonumber(cRateString)
    --Room Size. Req.
                        infobox = infobox .. acceptedType .. ' at ' .. consumingRate .. ' L'
    if itemTable.roomSizeReq ~= nil then
                        if (a ~= #itemTable.fluidsUsed) then
        section = section .. sectionRow('Room Size', itemTable.roomSizeReq, nil, '')
                            infobox = infobox .. ', '
    end
                        end
 
                    end
    --Room Mat. Req.
                infobox = infobox .. '\n'
    if itemTable.roomMatReq ~= nil then
        section = section .. sectionRow('Room Materials', itemTable.roomMatReq)
--Output (liquidProduced)
    end
infobox = infobox .. '|-\n| Output: \n| style=\"text-align: right;\" | '  
    return section
for a,b in ipairs(itemTable.fluidsProduced) do
end
local producedType = b[1]
 
                        local pRateString = string.gsub(b[2], "%s+", "")
function objectFormSection(itemTable, itemImageName)
                        local producingRate = tonumber(pRateString)
    return sectionImage(itemImageName, 'Form')
if (producingRate == 0) then
end
producingRate = 'Rate of Input'
 
end
function housingSection(itemTable)
infobox = infobox .. producedType .. ' at ' .. producingRate .. ' L'
    -- Housing Header
if (a ~= #itemTable.fluidsProduced) then
    section = sectionHeader('Housing')
infobox = infobox .. ', '
 
end
    --roomCategory
end
    section = section .. sectionRow('Room Category', itemTable.roomCategory) .. '[[Category:' .. itemTable.roomCategory .. ']]\n'
infobox = infobox .. '\n'
 
end
    if itemTable.roomCategory ~= L.t('Industrial') then
        if itemTable.furnitureType ~= nil then
-- 'Pollution Section (if pollution by Object)
            --furnitureType
-- if itemTable.pollution ~= nil then
            section = section .. sectionRow('Furniture Type', itemTable.furnitureType) .. '[[Category:' .. itemTable.furnitureType .. ']]\n'
-- Pollution Header
 
-- infobox = infobox .. '|- style=\"background-color: #4B9130; text-align: center;\"\n| colspan=\"2\" | \'\'\'Pollution\'\'\'\n'
            --Value of the object
            section = section .. sectionRow('Value', itemTable.skillValue)
--Pollution is caused by Object
 
-- infobox = infobox .. '|-\n| Fuels Used:\n| style=\"text-align: right;\" | ' .. itemTable.pollution .. '\n'
            --Dim. Return % of Object
            section = section .. sectionRow('Dim. Return %', itemTable.repeatsDepreciation * 100, nil, '%')
--Pollution Created
        end
-- infobox = infobox .. '|-\n| Fuels Used:\n| style=\"text-align: right;\" | ' .. itemTable.pollutionProduced .. '\n'
    end
-- end
 
    if itemTable.roomCategory == L.t('Industrial') then
end
        section = section .. "|- style=\"background-color: #red; text-align: center;\"\n| colspan=\"2\" | '''" .. L.t('ALL ROOM VALUE LOST') .. "'''\n"
    end
-- 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 storageSection(itemTable)
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Placed.png|[[Category:Pages_with_missing_placed]]'
    -- Storage Header
if mw.title.makeTitle('File', itemimagename .. '_Placed.png').file.exists then
    section = sectionHeader('Storage')
image = itemimagename .. '_Placed.png'
 
elseif mw.title.makeTitle('File', itemimagename .. '_Placed.jpg').file.exists then
    --Inventory Slots
image = itemimagename .. '_Placed.jpg'
    section = section .. sectionRow('Inventory Slots', itemTable.inventorySlots)
end
 
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
    --inventoryMaxWeight
end
    if itemTable.inventoryMaxWeight ~= nil then
        maxWeightKg = itemTable.inventoryMaxWeight / 1000
infobox = infobox .. '|}'
        section = section .. sectionRow('Inventory Max Weight', maxWeightKg, nil, 'kg')
return infobox
    else
end
        section = section .. sectionRow('Inventory Max Weight', L.t('Unlimited'))
    end
 
    return section
end
 
function powerSection(itemTable)
    -- Power Header
    section = sectionHeader('Power')
 
    --EngergyType
    section = section .. sectionRow('Energy Type', itemTable.energyType) .. '[[Category:' .. itemTable.energyType .. ']]\n'
 
    --Grid Radius
    section = section .. sectionRow('Grid Radius', itemTable.gridRadius, nil, 'm')
 
    --Energy Produced
    section = section .. sectionRow('Energy Produced', itemTable.energyProduced, nil, 'w')
 
    --Energy Used
    section = section .. sectionRow('Energy Used', itemTable.energyUsed, nil, 'w')
 
    return section
end
 
function fuelsSection(itemTable)
    -- Fuel Header
    section = sectionHeader('Fuel')
 
    --Fuels Used by Object
    section = section .. sectionRow('Fuels Used', '[[' .. L.t('%s Tag'):format(itemTable.fuelsUsed:gsub('[%[%]]+', '')) .. ']]')
 
    return section
end
 
function fluidsSection(itemTable)
    -- Liquid/Gas Header
    section = sectionHeader('Liquid/Gas')
 
    --Input (fludisUsed)
    if itemTable.fluidsUsed ~= nil then
        local list = ''
        for a, b in ipairs(itemTable.fluidsUsed) do
            local acceptedType = b[1]
            local cRateString = string.gsub(b[2], "%s+", "")
            local consumingRate = tonumber(cRateString)
            list = list .. L.t('%s at %sL'):format(acceptedType, consumingRate)
 
            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
function p.ItemMain(frame)
function p.ItemMain()
     -- get args from the Template
     -- get args from the Template
     local args = Utils.normaliseArgs(frame)
     local args = norm()
 
   
     -- 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: