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.

Module:Infobox Item: Difference between revisions

From Eco - English Wiki
[unchecked revision][unchecked revision]
No edit summary
(Undo revision 4341 by ZeelNightwolf (talk))
Tag: Undo
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 = {}


-- Header for the wikitable
-- Grabs args from the parent frame
function header( args )
-- Trims and parses the args into a table, then returns the table
     local headerStr = '{| class=\"wikitable mw-collapsible\" style=\"text-align: center;\"\n|-\n'
function norm()
 
     local origArgs = mw.getCurrentFrame():getParent().args
     -- Show or hide the Crafting Station column
    local args = {}
     if args[1] == '1' then
      
         headerStr = headerStr .. '! Crafting Station !'
     for k, v in pairs( origArgs ) do
        v = mw.text.trim( tostring( v ) )
        if v ~= '' then
            args[k] = v
         end
     end
     end
 
      
    -- Item, Level Needed, Materials, Related Specialty
     return args
     headerStr = headerStr .. '! colspan=\"4\" | Item !! colspan=\"4\" | Materials !! Level Needed !! Crafting Time <br>(mins) !! Labour Cost || XP Gain !! style="width: 100px" | Related <br> Specialty\n'
 
     return headerStr
end
end


function imagedisp( name )
-- Build an Item Infobox
    local str = ''
function itemBox( args, itemData )
local image = ''
     -- check that all necessary arguments are passed correctly
     -- Manual override for image file
     if args.name == nil or args.name == '' then
     if name then
        return '\'name\' must be specified.'
image = string.gsub(name, ' ', '') .. '_Icon.png'
    end
str = str .. ' <div class="iconContainer"><div class="iconStack">[[File:' .. image .. '|center|50px|link=' .. name .. '|class=iconBlue]]</div><div class=iconBorder style=\"position:absolute;\"></div></div> '
      
else
local item = args.name
image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. name .. '_Icon.png'
local itemTable = itemData.items[item]
str = str .. '[[File:' .. image .. '|frameless|50px|class=iconBlue]]'
end
str = str .. '<br> [[' .. name .. ']]'
return str
end
 
function stationcell( args )
  local str = ''
str = str .. '| ' .. imagedisp(args[1])
return str
end
 
 
function itemcell( args )
     local str = ''
str = str .. '| ' .. imagedisp(args[1])
str = str .. '<br>x' .. args[2] .. '\n'
return str
end
 
function skillreqcell( args )
    local str = ''
str = str .. '| ' .. imagedisp(args[1])
str = str .. '<br> Level ' .. args[2] .. ' \n'
return str
end


function groupedskillcell( args )
if itemTable == nil then
    local str = ''
return item .. ' could not be found in Module:ItemData.'
str = str .. '| ' .. imagedisp(args[1])
if args[2] ~= nil then
str = str .. ' <br> ' .. imagedisp(args[2])
end
end
return str
end


-- Create a wikitable of recipes
    local itemType = itemTable.type
function p.main( recipes )
local itemEN = string.sub (itemType, 1, -5)
    local rows = ''
local itemimagename = string.gsub(itemEN, ' ', '')
   
    -- string used to build the infobox
    local infobox = '{| class=\"infobox\"\n'
   
-- 'Name and Image' section
-- name of the item
infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; 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: '
    --Not relevant for v0.9
if itemTable.group == 'Food' then
    -- find number of times each Affect by Skill occurs
infobox = infobox .. '#85D66B;\"\n| colspan=\"2\" | \'\'\'Food\'\'\'\n'
    --local prevSkill = recipes[1].efficiencySkills[1]
-- Items:Food Icon Image
    --local skillIndex = {}
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Icon.png|[[Category:Pages_with_missing_icon]]'
    --local prevSkillnum = 0
if mw.title.makeTitle('File', itemimagename .. '_Icon.png').file.exists then
--local count = 0
image = itemimagename .. '_Icon.png'
    --for num = 1, #recipes do
elseif mw.title.makeTitle('File', itemimagename .. '_Icon.jpg').file.exists then
--if prevSkill ~= recipes[num].efficiencySkills[1] then
image = itemimagename .. '_Icon.jpg'
--skillIndex[#skillIndex + 1] = prevSkillnum + count
end
--prevSkillnum = 1
--if #recipes[num].ingredients > 4 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'
--count = 1
--else
elseif itemTable.group == 'Skill Books' then
--count = 0
infobox = infobox .. '#FFCF4D;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
--end
-- Items:Skill Book Icon Image
--prevSkill = recipes[num].efficiencySkills[1]
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'
--else
--prevSkillnum = prevSkillnum + 1
--if #recipes[num].ingredients > 4 then
--count = count + 1
--end
--end
    --end
    --skillIndex[#skillIndex + 1] = prevSkillnum + count
    -- Get each row
elseif itemTable.group == 'Skill Scrolls' then
    local j = 0
infobox = infobox .. '#FFCF4D;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
    local k = 1
-- Items:Skill Scrolls Icon Image
    for i = 1, #recipes do
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'
 
-- get information from the current recipe for building
else
local checkImage = recipes[i].checkImage
infobox = infobox .. '#78B1FF;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
local craftStn = recipes[i].craftStn
-- Items: Other Icon Image
local skillNeeds = recipes[i].skillNeeds
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Icon.png|[[Category:Pages_with_missing_icon]]'
--use last variant as this is always the default variant
if mw.title.makeTitle('File', itemimagename .. '_Icon.png').file.exists then
local numberOfVariants = recipes[i].numberOfVariants
image = itemimagename .. '_Icon.png'
local products = {{'',''}}
elseif mw.title.makeTitle('File', itemimagename .. '_Icon.jpg').file.exists then
local ingredients = {{'',''}}
image = itemimagename .. '_Icon.jpg'
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
   
  -- 'Description' section header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n'
--loop through variants to select default variant ingredients
if itemTable.description == nil then
for k, v in pairs(recipes[i].variants) do
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
--given pairs doesn't guarantee order, check that product matches default variant
elseif itemTable.description == '' then
if v.products[1][1] == recipes[i].defaultVariant then
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
ingredients = v.ingredients
else
products = v.products
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. itemTable.description .. '\n'
else
--handle scenarios where product ~= default variant (for example Refine Tallow)
ingredients = v.ingredients
products = v.products
end
end
end
local baseCraftTime = recipes[i].baseCraftTime
local baseLaborCost = recipes[i].baseLaborCost
    -- 'General' section header
local baseXPGain = recipes[i].baseXPGain
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'General\'\'\'\n'
   
-- determine the size needed for products to display correctly
-- -- created at
local ingrednum = #ingredients
-- local craftingRecipes = require( "Module:CraftingRecipes" )
local rowspan = '|'
-- local recipes = craftingRecipes.recipes
local rowspanProducts = '|'
-- local function addToSet(set, key)
-- set[key] = true
-- end
-- local function setNotContains(set, key)
-- return set[key] == nil
-- end
-- if craftingRecipes.items[item] ~= nil and #craftingRecipes.items[item] >= 1 then
-- local count = 0
-- local stations = {}
-- local sortStations = {}
-- local stationString = ''
-- local found = false
-- for k, v in ipairs( craftingRecipes.items[item] ) do
-- 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]) then
-- addToSet(stations, recipes[v].craftStn[1])
-- 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
--Code to incorporate rowspan for ingrediants and variants here
-- local track = 0
local rowspanCount = 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| Created at:\n| style=\"text-align: right; padding: 3px;\" | N/A\n'
-- end
-- elseif args.created ~= nil and args.created ~= '' then
-- infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right; padding: 3px;\" | ' .. args.created .. '\n'
-- else
-- infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right; padding: 3px;\" | N/A\n'
-- end


--accomodate both variants and multiple ingredients
-- calories and nutrients (if itemTable.group == 'Food')
if itemTable.group == 'Food' then
if ingrednum > 4 then
infobox = infobox .. '|-\n| Calories:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.calories .. '\n|- valign=\"center\"\n| rowspan=\"4\" | Nutrients:\n'
rowspanCount = rowspanCount + 2
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
end
--suspect there will be a bug here for many variants & many ingredients - might need x2 multipler per variant.
if(#recipes == 1) then --only add variant rowspans if there is one recipe (i.e. variants will be displayed)
-- yield
if tonumber(recipes[i].numberOfVariants) > 1 then
if itemTable.yield ~= nil then
rowspanCount = rowspanCount + tonumber(recipes[i].numberOfVariants)
infobox = infobox .. '|-\n| Improve Gathering: \n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.yield .. '\n'
rowspanProducts = '| rowspan=\"' .. rowspanCount - recipes[i].numberOfVariants - 1 .. '\" '
end
end
-- fuel
if itemTable.fuel ~= nil then
infobox = infobox .. '|-\n| Fuel energy:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.fuel .. ' J\n'
end
end
if rowspanCount > 0 then
   
rowspan = '| rowspan=\"' .. rowspanCount .. '\" '
-- currency
if(#recipes > 1) then
if itemTable.currency ~= nil then
rowspanProducts = '| rowspan=\"' .. rowspanCount .. '\" '
infobox = infobox .. '|-\n| Used as Currency:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.currency .. '\n'
else
rowspanProducts = '| rowspan=\"' .. rowspanCount - recipes[i].numberOfVariants - 1 .. '\" '
end
end
end
    -- 'IDs' section header
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'


-- Tags Header
--original rowspan working
if itemTable.tagGroups ~= nil and itemTable.tagGroups ~= {} then
--if ingrednum > 4 then
            -- Tags Header
-- rowspan = '| rowspan=\"2\" '
            infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Tags\'\'\'\n'
--end
            local tags = itemTable.tagGroups
            local list = ''
-- String to return
            -- for each item in the list (a is position, b is value)           
local row = '|-\n'
            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
                    list = list .. b
                end
                -- if not the last item in the list
                if (b ~= tags[#tags]) then
                    -- add a comma
                    list = list .. ', '
                end
            end
            -- Now the list is made add it to the infobox
            infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. list .. '\n'
        end
 
    -- 'Item' World Object header (if itemTable.group = Placeable or Blocks)
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'
-- Add new row if products or ingredients are passed in with at least 1 item
-- Object Placed Image
if (products[1] and ingredients[1]) then
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
-- Show or hide the Crafting Station column
image = itemimagename .. '_Placed.png'
if recipes[i].dispCraftStn == '1' then
elseif mw.title.makeTitle('File', itemimagename .. '_Placed.jpg').file.exists then
row = row .. rowspan .. stationcell({craftStn[1]}) .. '\n'
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: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Placement\'\'\'\n'
 
--Vechile
if itemTable.mobile ~= nil then
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
end
       
-- Add the products columns
--Material Tier
local prodnum = #products
if itemTable.materialTier ~= nil or itemTable.materialTier == 0 then
for a = 1, prodnum do
infobox = infobox .. '|-\n| Room Material:\n| style=\"text-align: right; padding: 3px;\" | Tier ' .. itemTable.materialTier .. '\n'
if prodnum == 1 then
row = row .. rowspanProducts .. ' colspan=\"4\" '
end
if ((prodnum == 2) or (prodnum == 3 and a == 2)) then
row = row .. rowspanProducts .. ' colspan=\"2\" '
end
row = row .. itemcell({products[a][1], products[a][2]})
end
end
-- Add the FIRST row of Ingredients column
--Room Req.
local numing = ingrednum
if itemTable.roomContainReq ~= nil then
if ingrednum > 4 then  
infobox = infobox .. '|-\n| Room Required:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomContainReq .. '\n'
numing = 4
end
end
for b = 1, numing do
if (ingrednum == 1) then
row = row .. '| colspan=\"4\" '
end
if ((ingrednum == 2) or (ingrednum == 3 and b == 2)) then
row = row .. '| colspan=\"2\" '
end
row = row .. itemcell({ingredients[b][2], ingredients[b][3]})
end
 
-- Add the Skill needed column
if (skillNeeds[1] ~= '' and skillNeeds[1] ~= nil) then
row = row .. rowspan .. skillreqcell({skillNeeds[1][1], skillNeeds[1][2]})
else
row = row .. rowspan
if ingrednum > 4 then
row = row .. '|'
end
row = row .. ' \'\'None\'\' \n'
end
-- Add the Crafting time column
--Room Size. Req.
row = row .. rowspan
if itemTable.roomSizeReq ~= nil then
if rowspanCount > 1 then
infobox = infobox .. '|-\n| Room Size:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomSizeReq .. ' \n'
row = row .. '|'
end
if baseCraftTime then
row = row .. baseCraftTime .. '\n'
else
row = row .. rowspan .. ' \'\'missing\'\' \n'
end
end
-- Add the Labour time column
--Room Mat. Req.
row = row .. rowspan
if itemTable.roomMatReq ~= nil then
if rowspanCount > 1 then
infobox = infobox .. '|-\n| Room Materials:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomMatReq .. '\n'
row = row .. '|'
end
end
if baseLaborCost then
row = row .. baseLaborCost .. '\n'
else
row = row .. rowspan .. ' \'\'missing\'\' \n'
end
-- Add the XP gain column
-- Object Form Image
row = row .. rowspan
if itemTable.group == 'Block Items' then
if rowspanCount > 1 then
local image = 'NoImage.png|link=https://wiki.play.eco/index.php?title=Special:Upload&wpDestFile=' .. itemimagename .. '_Form.png|[[Category:Pages_with_missing_form]]'
row = row .. '|'
if mw.title.makeTitle('File', itemimagename .. '_Form.png').file.exists then
end
image = itemimagename .. '_Form.png'
if baseXPGain then
elseif mw.title.makeTitle('File', itemimagename .. '_Form.jpg').file.exists then
row = row .. baseXPGain .. '\n'
image = itemimagename .. '_Form.jpg'
else
end
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | [[File:' .. image .. '|center|border|240px]]\n'
row = row .. rowspan .. ' \'\'missing\'\' \n'
end
end
 
-- 'Housing' section (if there is a Room Category)
-- not in v0.9
if itemTable.roomCategory ~= nil then  
-- Add the Affect by Skills column IF new skill grouping
-- Housing Header
--if j == 0 and (recipes[i].efficiencySkills[1] ~= nil and recipes[i].efficiencySkills[1] ~= 'nil') then
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Housing\'\'\'\n'
--row = row .. '| rowspan=\"' .. skillIndex[k] .. '\" ' .. groupedskillcell({recipes[i].efficiencySkills[1], recipes[i].speedSkills}) .. '\n'
   
--elseif (recipes[i].efficiencySkills[1] == nil or recipes[i].efficiencySkills[1] == 'nil')  then
--roomCategory
--row = row .. '| \n'
infobox = infobox .. '|-\n| Room Category:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.roomCategory .. '\n'
--end
 
--j = j + 1
if itemTable.roomCategory ~= 'Industrial' then
--if #ingredients > 4 then
if itemTable.furnitureType ~= nil then  
--j = j + 1
--furnitureType
--end
infobox = infobox .. '|-\n| Furniture Type:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.furnitureType .. '\n'
--if j == skillIndex[k] then
           
--k = k + 1
--Value of the object
--j = 0
infobox = infobox .. '|-\n| Value:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.skillValue .. '\n'
--end
           
--Dim. Return % of Object 
-- Add the SECOND row of ingredients to ingredients column if applicable
infobox = infobox .. '|-\n| Dim. Return %:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.repeatsDepreciation .. '\n'  
if ingrednum > 4 then
row = row .. '|-\n'
for b = 5, ingrednum do
if (ingrednum == 5) then
row = row .. '| colspan=\"4\" '
end
end
if ((ingrednum == 6) or (ingrednum == 7 and b == 6)) then
end
row = row .. '| colspan=\"2\" '
end
if itemTable.roomCategory == 'Industrial' then
row = row .. itemcell({ingredients[b][2], ingredients[b][3]})
infobox = infobox .. '|- style=\"background-color: red; text-align: center;\"\n| colspan=\"2\" | \'\'\'ALL ROOM VALUE LOST\'\'\'\n'
end
end
end
end
-- 'Storage' Section (if inventorySlots is not nil)
rows = rows .. row
if itemTable.inventorySlots ~= nil then
end
-- Storage Header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Storage\'\'\'\n'
 
--Inventory Slots
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
 
-- 'Power' section (if EngeryType is ``not nil)
if itemTable.energyType ~= nil then 
-- Power Header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Power\'\'\'\n'


--Show variants in table if only 1 recipe in list
--EngergyType
if #recipes == 1 and tonumber(recipes[i].numberOfVariants) > 1 then
infobox = infobox .. '|-\n| Energy Type:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyType .. '\n'
for k, v in pairs(recipes[i].variants) do
--start new row for variants
--Grid Radius
row = '|-\n'
infobox = infobox .. '|-\n| Grid Radius:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.gridRadius .. ' m\n'
--Skip default variant
if v.products[1][1] ~= recipes[i].defaultVariant then
--Energy Produced
local prodnum = #products
infobox = infobox .. '|-\n| Energy Produced:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyProduced .. ' J\n'
for a = 1, prodnum do
if prodnum == 1 then
--Energy Used
row = row .. rowspanProducts .. ' colspan=\"4\" '
infobox = infobox .. '|-\n| Energy Used:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyUsed .. ' J\n'
end
end
if ((prodnum == 2) or (prodnum == 3 and a == 2)) then
row = row .. rowspanProducts .. ' colspan=\"2\" '
end
row = row .. itemcell({v.products[a][1], v.products[a][2]})
end


--will need to cycle ingrediants to fill out complete table
-- 'Fuel' Section (if fuelsUsed by Object)
--row = row .. itemcell({v.products[1][1], v.products[1][2]})
if itemTable.fuelsUsed ~= nil then
local numing = ingrednum
-- Fuel Header
if ingrednum > 4 then  
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Fuel\'\'\'\n'
numing = 4
end
--Fuels Used by Object
for b = 1, numing do
infobox = infobox .. '|-\n| Fuels Used:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.fuelsUsed .. '\n'
if (ingrednum == 1) then
end
row = row .. '| colspan=\"4\" '
-- 'Fluid' section (if fludisUsed is not nil)   
            if itemTable.fluidsUsed ~= nil then
            -- Liquid/Gas Header
                infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Liquid/Gas\'\'\'\n'
           
                --Input (fludisUsed)
                infobox = infobox .. '|-\n| Input: \n| style=\"text-align: right; padding: 3px;\" | '
                    for a,b in ipairs(itemTable.fluidsUsed) do
                        local acceptedType =  b[1]
                        local cRateString = string.gsub(b[2], "%s+", "")
                        local consumingRate = tonumber(cRateString)
                        infobox = infobox .. acceptedType .. ' at ' .. consumingRate .. ' L'
                        if (a ~= #itemTable.fluidsUsed) then
                            infobox = infobox .. ', '
                        end
                    end
                infobox = infobox .. '\n'
--Output (liquidProduced)
infobox = infobox .. '|-\n| Output: \n| style=\"text-align: right; padding: 3px;\" | '
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
end
if ((ingrednum == 2) or (ingrednum == 3 and b == 2)) then
infobox = infobox .. producedType .. ' at ' .. producingRate .. ' L'
row = row .. '| colspan=\"2\" '
if (a ~= #itemTable.fluidsProduced) then
infobox = infobox .. ', '
end
end
row = row .. itemcell({v.ingredients[b][2], v.ingredients[b][3]})
end
end
infobox = infobox .. '\n'
end
end
end
rows = rows .. row
end
-- Road Object header (if group == Road Items)
 
if itemTable.group == 'Road Items' then
infobox = infobox .. '|- style=\"text-align: center; background-color: #517ab2;\"\n| colspan=\"2\" | \'\'\'Road 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'
end
end
infobox = infobox .. '|}'
return infobox
end
end


-- Main entry point for the Module
function p.ItemMain()
     -- Return the full wikitable
     -- get args from the Template
return header({recipes[1].dispCraftStn}) .. rows .. '|-\n|}\n'
    local args = norm()
   
    -- get item data
    local itemData = require( "Module:ItemData" )
    return itemBox( args, itemData )
end
end


return p
return p

Revision as of 04:29, 4 October 2020

Documentation

This module provides the back end functionality of the Template:Infobox_Item.

If the template is passed an Infobox will be made using details from the following Modules:

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.


-- 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 = {}

-- Grabs args from the parent frame
-- Trims and parses the args into a table, then returns the table
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
function itemBox( args, itemData )
    -- check that all necessary arguments are passed correctly
    if args.name == nil or args.name == '' then
        return '\'name\' must be specified.'
    end
    
	local item = args.name
	local itemTable = itemData.items[item]

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

    local itemType = itemTable.type
	local itemEN = string.sub (itemType, 1, -5)
	local itemimagename = string.gsub(itemEN, ' ', '')
    
    -- string used to build the infobox
    local infobox = '{| class=\"infobox\"\n'
    
	-- 'Name and Image' section
		-- name of the item
		infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; 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 .. '#85D66B;\"\n| colspan=\"2\" | \'\'\'Food\'\'\'\n'
			-- Items:Food 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]]'
			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
			
    		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'
		
		elseif itemTable.group == 'Skill Books' then
			infobox = infobox .. '#FFCF4D;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\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'
	
		elseif itemTable.group == 'Skill Scrolls' then
			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'
	
		else
			infobox = infobox .. '#78B1FF;\"\n| colspan=\"2\" | \'\'\'' .. itemTable.group .. '\'\'\'\n'
			-- 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]]'
			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
    		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
    
		  -- 'Description' section header
		infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n'	
		
		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
	
    -- 'General' section header
		infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'General\'\'\'\n'
    
		-- -- created at
		-- local craftingRecipes = require( "Module:CraftingRecipes" )
		-- local recipes = craftingRecipes.recipes
	
		-- local function addToSet(set, key)
			-- set[key] = true
		-- end
	
		-- local function setNotContains(set, key)
			-- return set[key] == nil
		-- end
	
		-- if craftingRecipes.items[item] ~= nil and #craftingRecipes.items[item] >= 1 then
			-- local count = 0
			-- local stations = {}
			-- local sortStations = {}
			-- local stationString = ''
			-- local found = false
			-- for k, v in ipairs( craftingRecipes.items[item] ) do
				-- 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]) then
							-- addToSet(stations, recipes[v].craftStn[1])
							-- 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
		
			-- 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| Created at:\n| style=\"text-align: right; padding: 3px;\" | N/A\n'
			-- end
		-- elseif args.created ~= nil and args.created ~= '' then
			-- infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right; padding: 3px;\" | ' .. args.created .. '\n'
		-- else
			-- infobox = infobox .. '|-\n| Created at:\n| style=\"text-align: right; padding: 3px;\" | N/A\n'
		-- 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
		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'

	-- Tags Header
		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
                    list = list .. b
                end
                -- if not the last item in the list
                if (b ~= tags[#tags]) then
                    -- add a comma
                    list = list .. ', '
                end
            end
            -- Now the list is made add it to the infobox
            infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. list .. '\n'
        end

    -- 'Item' World Object header (if itemTable.group = Placeable or Blocks)
		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: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Placement\'\'\'\n'

			--Vechile
			if itemTable.mobile ~= nil then
				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 .. '\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	

		-- 'Housing' section (if there is a Room Category)
			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 .. '\n'

				if itemTable.roomCategory ~= 'Industrial' then
					if itemTable.furnitureType ~= nil then 
					--furnitureType
						infobox = infobox .. '|-\n| Furniture Type:\n| style=\"text-align: right; padding: 3px;\" | ' .. 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'

				--Inventory Slots
				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	

		-- 'Power' section (if EngeryType is ``not nil)
			if itemTable.energyType ~= nil then  
				-- Power Header
				infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Power\'\'\'\n'

				--EngergyType 
				infobox = infobox .. '|-\n| Energy Type:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.energyType .. '\n'
		
				--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	

			-- 'Fuel' Section (if fuelsUsed by Object)
			if itemTable.fuelsUsed ~= nil then
				-- Fuel Header
				infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Fuel\'\'\'\n'
	
				--Fuels Used by Object
				infobox = infobox .. '|-\n| Fuels Used:\n| style=\"text-align: right; padding: 3px;\" | ' .. itemTable.fuelsUsed .. '\n'
			end
	
 -- 'Fluid' section (if fludisUsed is not nil)    
            if itemTable.fluidsUsed ~= nil then 
            -- Liquid/Gas Header
                infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Liquid/Gas\'\'\'\n'
            
                --Input (fludisUsed) 
                infobox = infobox .. '|-\n| Input: \n| style=\"text-align: right; padding: 3px;\" | ' 
                    for a,b in ipairs(itemTable.fluidsUsed) do
                        local acceptedType =  b[1]
                        local cRateString = string.gsub(b[2], "%s+", "")
                        local consumingRate = tonumber(cRateString)
                        infobox = infobox .. acceptedType .. ' at ' .. consumingRate .. ' L'
                        if (a ~= #itemTable.fluidsUsed) then
                            infobox = infobox .. ', '
                        end
                    end
                infobox = infobox .. '\n'
		
				--Output (liquidProduced)
				infobox = infobox .. '|-\n| Output: \n| style=\"text-align: right; padding: 3px;\" | ' 
					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
						infobox = infobox .. producedType .. ' at ' .. producingRate .. ' L'
						if (a ~= #itemTable.fluidsProduced) then
							infobox = infobox .. ', '
						end
					end
				infobox = infobox .. '\n'
			end
		end
	
	-- Road Object header (if group == Road Items)
		if itemTable.group == 'Road Items' then
		infobox = infobox .. '|- style=\"text-align: center; background-color: #517ab2;\"\n| colspan=\"2\" | \'\'\'Road 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'
		end
	
	infobox = infobox .. '|}'
	return infobox
	end
	

-- Main entry point for the Module
function p.ItemMain()
    -- get args from the Template
    local args = norm()
    
    -- get item data
    local itemData = require( "Module:ItemData" )
    return itemBox( args, itemData )
end

return p