[SOLVED]Struggling with item icons. Error : Value must be a dictionary in property tree at ROOT.item.Turbine-MK2.icons.

Place to get help with not working mods / modding interface.
Post Reply
yourzone
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Jul 20, 2023 10:52 am
Contact:

[SOLVED]Struggling with item icons. Error : Value must be a dictionary in property tree at ROOT.item.Turbine-MK2.icons.

Post by yourzone »

I am trying to make a mod and I keep getting this error:

Failed to load mods: Error while loading item prototype "Turbine-MK2" (item): Value must be a dictionary in property tree at ROOT.item.Turbine-MK2.icons.icon
Modifications: Turbine MK2


here my code:

Code: Select all

--item.lua

local turbin_MK2_item = table.deepcopy(data.raw["item"]["steam-turbine"])
    turbin_MK2_item.name = "Turbine-MK2"
    turbin_MK2_item.icons = {
        icon = turbin_MK2_item.icon,
        tint = {r=1,g=0.5,b=0.5,a=0.5}
    }
    

--[[
    local turbin_MK2_entity = table.deepcopy(data.raw.generator["steam-turbine"]) 
    turbin_MK2_entity.name = "turbin_MK2_entity"
    turbin_MK2_entity.fluid_usage_per_tick = 4
    turbin_MK2_entity.burns_fluid = false
    turbin_MK2_entity.scale_fluid_usage = false
    turbin_MK2_entity.maximum_temperature = 500
    turbin_MK2_entity.minable.result = "turbin_MK2"
    turbin_MK2_entity.energy_source.usage_priority = "primary-output"
    turbin_MK2_entity.fluid_box.filter = "steam"
    turbin_MK2_entity.max_power_output = "40MW"
]]


local turbinMK2_recipe = table.deepcopy(data.raw["recipe"]["steam-turbine"])
    turbinMK2_recipe.enabled = true
    turbinMK2_recipe.name = "Turbine-MK2"
    turbinMK2_recipe.ingredients = {
        {type="item", name="iron-plate", amount=200},
        {type="item", name="iron-gear-wheel", amount=200},
        {type="item", name="steam-turbine", amount=5},
    }
    turbinMK2_recipe.result = "turbin_MK2"

data:extend{turbin_MK2_item,turbinMK2_recipe}

I based my code loosely on this :https://wiki.factorio.com/Tutorial:Modd ... e_creation

I tried many things but it always comes back to this error.
Last edited by yourzone on Thu Jul 20, 2023 11:18 pm, edited 1 time in total.

User avatar
Stringweasel
Filter Inserter
Filter Inserter
Posts: 321
Joined: Thu Apr 27, 2017 8:22 pm
Contact:

Re: Struggling with item icons. Error : Value must be a dictionary in property tree at ROOT.item.Turbine-MK2.icons.icon

Post by Stringweasel »

yourzone wrote:
Thu Jul 20, 2023 11:02 am
I am trying to make a mod and I keep getting this error:

Failed to load mods: Error while loading item prototype "Turbine-MK2" (item): Value must be a dictionary in property tree at ROOT.item.Turbine-MK2.icons.icon
Modifications: Turbine MK2


here my code:

Code: Select all

--item.lua

local turbin_MK2_item = table.deepcopy(data.raw["item"]["steam-turbine"])
    turbin_MK2_item.name = "Turbine-MK2"
    turbin_MK2_item.icons = {
        icon = turbin_MK2_item.icon,
        tint = {r=1,g=0.5,b=0.5,a=0.5}
    }
    

--[[
    local turbin_MK2_entity = table.deepcopy(data.raw.generator["steam-turbine"]) 
    turbin_MK2_entity.name = "turbin_MK2_entity"
    turbin_MK2_entity.fluid_usage_per_tick = 4
    turbin_MK2_entity.burns_fluid = false
    turbin_MK2_entity.scale_fluid_usage = false
    turbin_MK2_entity.maximum_temperature = 500
    turbin_MK2_entity.minable.result = "turbin_MK2"
    turbin_MK2_entity.energy_source.usage_priority = "primary-output"
    turbin_MK2_entity.fluid_box.filter = "steam"
    turbin_MK2_entity.max_power_output = "40MW"
]]


local turbinMK2_recipe = table.deepcopy(data.raw["recipe"]["steam-turbine"])
    turbinMK2_recipe.enabled = true
    turbinMK2_recipe.name = "Turbine-MK2"
    turbinMK2_recipe.ingredients = {
        {type="item", name="iron-plate", amount=200},
        {type="item", name="iron-gear-wheel", amount=200},
        {type="item", name="steam-turbine", amount=5},
    }
    turbinMK2_recipe.result = "turbin_MK2"

data:extend{turbin_MK2_item,turbinMK2_recipe}

I based my code loosely on this :https://wiki.factorio.com/Tutorial:Modd ... e_creation

I tried many things but it always comes back to this error.
Try this:

Code: Select all

local turbin_MK2_item = table.deepcopy(data.raw["item"]["steam-turbine"])
    turbin_MK2_item.name = "Turbine-MK2"
    turbin_MK2_item.icons = {
        {
            icon = turbin_MK2_item.icon,
            tint = {r=1,g=0.5,b=0.5,a=0.5}
        }
    }
The icons field requires an array of icons to be defined.
Alt-F4 Author | Factorio Modder
Mods: Hall of Fame | Better Victory Screen | Fluidic Power | Biter Power | Space Spidertron | Spidertron Dock | Weasel's Demolition Derby

yourzone
Manual Inserter
Manual Inserter
Posts: 2
Joined: Thu Jul 20, 2023 10:52 am
Contact:

Re: Struggling with item icons. Error : Value must be a dictionary in property tree at ROOT.item.Turbine-MK2.icons.icon

Post by yourzone »

Thanks that help a lot.

A lot of other things happen after (many more error).

here the final code that make it work:

Code: Select all

--entity
local turbin_MK2_entity = table.deepcopy(data.raw["generator"]["steam-turbine"]) 
    turbin_MK2_entity.name = "turbin_MK2_entity"
    turbin_MK2_entity.fluid_usage_per_tick = 4
    turbin_MK2_entity.burns_fluid = false
    turbin_MK2_entity.scale_fluid_usage = false
    turbin_MK2_entity.maximum_temperature = 500
    turbin_MK2_entity.minable.result = "Turbine-MK2"
    turbin_MK2_entity.energy_source.usage_priority = "primary-output"
    turbin_MK2_entity.fluid_box.filter = "steam"
    turbin_MK2_entity.max_power_output = "40MW"


--item
local turbin_MK2_item = table.deepcopy(data.raw["item"]["steam-turbine"])
    turbin_MK2_item.name = "Turbine-MK2"
    turbin_MK2_item.place_result = "turbin_MK2_entity"
    turbin_MK2_item.icons = {
        {
            icon = turbin_MK2_item.icon,
            tint = {r=1,g=0.5,b=0.5,a=0.5}
        }
    }
    

--recipe
local turbin_MK2_recipe = table.deepcopy(data.raw["recipe"]["steam-turbine"])
    turbin_MK2_recipe.enabled = true
    turbin_MK2_recipe.name = "Turbine-MK2"
    turbin_MK2_recipe.ingredients = {
        {type="item", name="iron-plate", amount=200},
        {type="item", name="iron-gear-wheel", amount=200},
        {type="item", name="steam-turbine", amount=5}
    }
    turbin_MK2_recipe.result = "Turbine-MK2"
  --[[   turbin_MK2_recipe.results = {
        {type = "item", name= "turbin_MK2_entity", amount =1}
    }  ]]

data:extend({
    turbin_MK2_entity,
    turbin_MK2_item,
    turbin_MK2_recipe
} )



--[[
    --[
    data:extend(
        {
        --recipes
        {
            type = 'recipe',
            name = 'turbin_MK2__recipe',
            enabled = false,
            ingredients = {
                {type="item", name="iron-plate", amount=200},
                {type="item", name="iron-gear-wheel", amount=200},
                {type="item", name="steam-turbine", amount=5},
            },
            results = {
                {type="item", name="turbin_MK2", amount=1},
            },
            result_count = 1,
            energy_required = 10,
        },
        --turbines
        {
            name = 'turbin_MK2',
            type = 'item',
            icon = "__base__/graphics/icons/steam-turbine.png",
            tint={r = 1, g = 0.5, b = 0, a = 0.5}, 
            icon_size = 64,
            subgroup = "energy",
            place_result = 'turbin_MK2',
            stack_size = 20,
            order = "f[nuclear-energy]-d[steam-turbine]",
        },
        --techs
        {
            name = 'turbin_MK2_tech',
            type = 'technology',
            icon = "__base__/graphics/icons/steam-turbine.png",
            tint={r = 1, g = 0.5, b = 0, a = 0.5}, 
            icon_size = 128,
            prerequisites = {"nuclear-power"},
            effects = {
                { 
                    type = 'unlock-recipe',
                    recipe = 'turbin_MK2_recipe',
                }
            },
            unit = {
                count = '2000',
                ingredients = {
                    {'chemical-science-pack',1},
                    {'automation-science-pack',1},
                    {'logistic-science-pack',1}
                },
                time = 100,
            },
        },
    })
    ]
]]

oh also I feel like I wont be liking lua (<- this happen a lot when I touch programming).

Post Reply

Return to “Modding help”