[SOLVED][HELP] data.raw Difficulty error

Place to get help with not working mods / modding interface.
User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 82
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

[SOLVED][HELP] data.raw Difficulty error

Post by dtoxic »

Ok so i tried to edit some stuff in another mod but i get a error because the difficulty (normal,expensive i think) is not defined in my code but neither is in the mod that i try to edit i think, any way here is the code and the error but i don't know where to define the difficulty

Code: Select all

data.raw.technology["power-cells"].prerequisites = {"electric-machinery"}
data.raw.technology["power-cells"].unit.ingredients = {count = 50, ingredients = "early-science-pack", 1, time = 10}

Code: Select all

Error
Failed to load mods: Error while loading technology prototype "power-cells" (technology): Difficulty normal: Value must be a dictionary in property tree at ROOT.technology.power-cells.unit.ingredients.1
Last edited by dtoxic on Wed Jan 25, 2023 5:21 pm, edited 1 time in total.

Hornwitser
Fast Inserter
Fast Inserter
Posts: 214
Joined: Fri Oct 05, 2018 4:34 pm
Contact:

Re: [HELP] data.raw Difficulty error

Post by Hornwitser »

This does not have anything to do with difficulty other than the place you put the ingredients to apply for normal difficulty. The documentation for ingredients state that it is a table of IngredientsPrototype. The error is saying it expected to find a table inside data.raw.technology["power-cells"].unit.ingredients[1], but it found the digit 1 instead. If you are confused you can use a log statement like

Code: Select all

log(serpent.block(data.raw.technology["power-cells"]))
to print out what the prototype looks like after you modified it to factorio-current.log.

DarkShadow44
Filter Inserter
Filter Inserter
Posts: 347
Joined: Thu Jun 01, 2017 12:05 pm
Contact:

Re: [HELP] data.raw Difficulty error

Post by DarkShadow44 »

You should look to other mods or the docs (not sure why I can't find technology.unit in the docs though).
Try

Code: Select all

data.raw.technology["automation"].unit = {count = 2, ingredients = {{"automation-science-pack", 4}}, time = 12}

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 82
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [HELP] data.raw Difficulty error

Post by dtoxic »

ok the "1" is for that science pack needed....so should i write "amount = 1" ?

here is the original code from the mod i am trying to change the automation science pack to a different science pack from a different mod and count and time
so i left the "1" there made sense to me...but then again me and my coding skill = -1

Code: Select all

data:extend({
    {
        type = "technology",
        name = "power-cells",
        icon = "__power-cells__/graphics/technology/capacitive-cell.png",
        icon_size = 256,
        effects = {
            {type = "unlock-recipe", recipe = "capacitive-power-cell"},
            {type = "unlock-recipe", recipe = "cell-charger"},
            {type = "unlock-recipe", recipe = "basic-power-station"}
        },
        prerequisites = nil,
        unit = {
            count = 30,
            ingredients = {{"automation-science-pack", 1}},
            time = 15
        }
        -- order = "c-e-b",
    }
})

DarkShadow44
Filter Inserter
Filter Inserter
Posts: 347
Joined: Thu Jun 01, 2017 12:05 pm
Contact:

Re: [HELP] data.raw Difficulty error

Post by DarkShadow44 »

Ah, prototype data is in the wiki: https://wiki.factorio.com/Prototype/Technology#unit
You can just follow that to get exactly what you need.
ok the "1" is for that science pack needed....so should i write "amount = 1" ?
Why don't you just test it? Copy my code and see what it does ;)

Wiki and "trial and error" are your friends, so are other open source mods.

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 82
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [HELP] data.raw Difficulty error

Post by dtoxic »

DarkShadow44 wrote:
Wed Jan 25, 2023 5:09 pm
You should look to other mods or the docs (not sure why I can't find technology.unit in the docs though).
Try

Code: Select all

data.raw.technology["automation"].unit = {count = 2, ingredients = {{"automation-science-pack", 4}}, time = 12}
Yeap this one works,thank you very much!!!

so basically i should have left out ".ingredients" after the "unit" part...and also one more pair of big brackets in the ingredients = part

DarkShadow44
Filter Inserter
Filter Inserter
Posts: 347
Joined: Thu Jun 01, 2017 12:05 pm
Contact:

Re: [HELP] data.raw Difficulty error

Post by DarkShadow44 »

Basically. the structure is this:

Code: Select all

unit -> dictionary
    count -> int
    time -> double
    ingredients -> array
    	ingredient1 -> array of name, count
    	...
As noted, the structure is laid out on the wiki.

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 82
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [SOLVED][HELP] data.raw Difficulty error

Post by dtoxic »

Thank you....will do some more trial and error and try figure it out more things,totally new to modding except some basic things

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 82
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [SOLVED][HELP] data.raw Difficulty error

Post by dtoxic »

One more question,should i be using data-updates or data-final-fixes for these shenanigans i am trying to do...i am using final fixes because i want them to run after all mods.

DarkShadow44
Filter Inserter
Filter Inserter
Posts: 347
Joined: Thu Jun 01, 2017 12:05 pm
Contact:

Re: [SOLVED][HELP] data.raw Difficulty error

Post by DarkShadow44 »

IMHO, I'd do it as soon as you can, just in case someone wants to alter your mod later :)
With a dependency, even data.lua should work, but I'd use updates.

User avatar
dtoxic
Long Handed Inserter
Long Handed Inserter
Posts: 82
Joined: Fri Apr 01, 2016 8:40 pm
Contact:

Re: [SOLVED][HELP] data.raw Difficulty error

Post by dtoxic »

yeah i added dependencies in the json file...so data-updates it is,it works as is now but will try it out..thx man for all the help i appreciate it!

Post Reply

Return to “Modding help”