2.0 mod porting void fuel, free science and free space science modifiers

Place to get help with not working mods / modding interface.
User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Sat Mar 02, 2019 7:06 am

2.0 mod porting void fuel, free science and free space science modifiers

Post by TheKillerChicken »

I am trying to port the void fuel, free science and free space science modifiers to 2.0 and am struggling with them. The science pack ones are spitting out Failed to load mods: Error in assignID: item with name 'science-pack' does not exist. I will update with the void fuel issues later on. This is my code:
for _, science in pairs(data.raw.tool) do

if string.match(science.name, "science") then
local orig = data.raw.recipe[science.name]
if orig then

local free_recipe = {
type = "recipe",
name = "free-science-pack",
enabled = true,
energy_required = 1,
ingredients = {},
category = "crafting",
subgroup = "science-pack",
order = science.order,
results = {{type="item", name="science-pack", amount=1}},
}
data:extend({free_recipe})
end
end
end
Bilka
Factorio Staff
Factorio Staff
Posts: 3357
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by Bilka »

Split from mod porting guide topic
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Bilka
Factorio Staff
Factorio Staff
Posts: 3357
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by Bilka »

Is https://mods.factorio.com/mod/FreeScience the mod you're trying to port? If yes, I think you don't need to change the code that much. It should be enough to change the "result = science.name" line to be "results = {{type = "item", name = science.name, amount = 1}}".
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Sat Mar 02, 2019 7:06 am

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by TheKillerChicken »

Bilka wrote: Mon Mar 24, 2025 7:13 am Is https://mods.factorio.com/mod/FreeScience the mod you're trying to port? If yes, I think you don't need to change the code that much. It should be enough to change the "result = science.name" line to be "results = {{type = "item", name = science.name, amount = 1}}".
The problem is that upon booting the game, it is stating that there is an error in assignID stating that 'science-pack' does not exist. Got if figured out, thanks for nudging me the right direction. The game executes without error now after I did a second take on your post. Now need your assistance with the void fuel mod. This is the modified code for void fuel:
data:extend(
{
{
type = "recipe",
category = "chemistry",
crafting_machine_tint =
{
primary =
{
a = 0,
b = 0.25,
g = 0,
r = 0.25
},
secondary =
{
a = 0,
b = 0.45,
g = 0,
r = 0.45
},
tertiary =
{
a = 0,
b = 0,
g = 0,
r = 0
}
},
name = "void-powder",
energy_required = 100,
enabled = false,
icon = "__VoidFuel__/graphics/void-powder.png",
icon_size = 32,
subgroup = "intermediate-product",
order = "q[voidfuel]-a",

ingredients = {{name = "sulfuric-acid",amount = 1000,type = "fluid"},

results = {{name = "void-powder", amount = 1, type = "item"},
},

{
type = "recipe",
name = "void-fuel",
energy_required = 500,
enabled = false,
icon = "__VoidFuel__/graphics/void-fuel1.png",
icon_size = 128,
subgroup = "intermediate-product",
order = "q[voidfuel]-a",

ingredients =
{
{type="item", name="nuclear-fuel", amount=5},
{type="item", name="void-powder", amount=10},
},
results = {{type="item", name="void-fuel", amount = 1},
},

{
type = "recipe",
name = "corruption-fuel",
energy_required = 1000,
enabled = false,
icon = "__VoidFuel__/graphics/void-fuel2.png",
icon_size = 128,
subgroup = "intermediate-product",
order = "q[voidfuel]-b",

ingredients =
{
{type="item", name="void-fuel", amount=5},
{type="item", name="void-powder", amount=10},
},
results = {{type"item", name="corruption-fuel", amount 1},
},

{
type = "recipe",
name = "quantum-fuel",
energy_required = 2000,
enabled = false,
icon = "__VoidFuel__/graphics/void-fuel3.png",
icon_size = 128,
subgroup = "intermediate-product",
order = "q[voidfuel]-b",

ingredients =
{
{type="item", name="corruption-fuel", amount=10},
{type="item", name="void-powder", amount=10},
},
results = {{type"item", name="quantum-fuel", amount 1},
}

}
)
sorry, one more modifier: Burner-fuel-bonus. I simply do not even know where to begin on updating the code for version 2.
User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Sat Mar 02, 2019 7:06 am

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by TheKillerChicken »

This is the error I am getting with void fuel: Failed to load mods:

__VoidFuel__/data.lua:2: __VoidFuel__/prototypes/recipe.lua:72: '}' expected near '1'
stack traceback:
[C]: in function 'require'
__VoidFuel__/data.lua:2: in main chunk

Mods to be disabled:
• VoidFuel (2.0.0)

I changed it a little in hopes that it would work:

data:extend(
{
{
type = "recipe",
category = "chemistry",
crafting_machine_tint =
{
primary =
{
a = 0,
b = 0.25,
g = 0,
r = 0.25
},
secondary =
{
a = 0,
b = 0.45,
g = 0,
r = 0.45
},
tertiary =
{
a = 0,
b = 0,
g = 0,
r = 0
}
},
name = "void-powder",
energy_required = 100,
enabled = false,
icon = "__VoidFuel__/graphics/void-powder.png",
icon_size = 32,
subgroup = "intermediate-product",
order = "q[voidfuel]-a",

ingredients = {type = "fluid", name = "sulfuric-acid", amount = 1000},

results = {{type = "item", name = "void-powder", amount = 1},
},

{
type = "recipe",
name = "void-fuel",
energy_required = 500,
enabled = false,
icon = "__VoidFuel__/graphics/void-fuel1.png",
icon_size = 128,
subgroup = "intermediate-product",
order = "q[voidfuel]-a",

ingredients = {type="item", name="nuclear-fuel", amount=5},
{type="item", name="void-powder", amount=10},
},
results = {{type="item", name="void-fuel", amount = 1}},
},

{
type = "recipe",
name = "corruption-fuel",
energy_required = 1000,
enabled = false,
icon = "__VoidFuel__/graphics/void-fuel2.png",
icon_size = 128,
subgroup = "intermediate-product",
order = "q[voidfuel]-b",

ingredients = {type="item", name="void-fuel", amount=5},
{type="item", name="void-powder", amount=10},
},
results = {{type"item", name="corruption-fuel", amount 1}},
},

{
type = "recipe",
name = "quantum-fuel",
energy_required = 2000,
enabled = false,
icon = "__VoidFuel__/graphics/void-fuel3.png",
icon_size = 128,
subgroup = "intermediate-product",
order = "q[voidfuel]-b",

ingredients = {type="item", name="corruption-fuel", amount=10},
{type="item", name="void-powder", amount=10},
},
results = {{type"item", name="quantum-fuel", amount 1}},
}

}
)
User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Sat Mar 02, 2019 7:06 am

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by TheKillerChicken »

Can anyone please help me here? I am trying to interpret the factorio API wiki, but I cannot.
Tertius
Smart Inserter
Smart Inserter
Posts: 1168
Joined: Fri Mar 19, 2021 5:58 pm
Contact:

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by Tertius »

You need to correct the syntax errors. There are missing "=".

Using an editor such as vscode with its lua plugin helps with writing code that doesn't contain such errors in the first place, since it reports any such error while you type.
User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Sat Mar 02, 2019 7:06 am

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by TheKillerChicken »

Tertius wrote: Wed Mar 26, 2025 9:58 am You need to correct the syntax errors. There are missing "=".

Using an editor such as vscode with its lua plugin helps with writing code that doesn't contain such errors in the first place, since it reports any such error while you type.
I use notepad++ for my editor/debugger. I really wish the Factorio error display was much more detailed is it is pretty vague. is it even at all possible to make the error display in detailed mode?
User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Sat Mar 02, 2019 7:06 am

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by TheKillerChicken »

This is another modifier I am having an issue with, I believe it is a false-positive from the engine itself as these values do not even exist in the code:

Failed to load mods: Error while loading item prototype "burner-fuel-bonus-stone-furnace" (item): Unknown flag "hidden"
Modifications: Burner Fuel Bonus

I am not going to link this code as it is very complex I will probably make fire breathe out of the Wube moderators by posting many lines of code.
User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Sat Mar 02, 2019 7:06 am

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by TheKillerChicken »

Truth is: I have a serious case of dyslexia, so learning code is utterly impossible. I really need people to guide me through these more complex issues with porting the code. I actually have been getting paranoid and now feel that the lua engine is reporting false-positives now.
User avatar
TheKillerChicken
Long Handed Inserter
Long Handed Inserter
Posts: 95
Joined: Sat Mar 02, 2019 7:06 am

Re: 2.0 mod porting void fuel, free science and free space science modifiers

Post by TheKillerChicken »

sorry, one more thing: the free-space-science is also very unintelligble for me:

data.raw["assembling-machine"]["assembling-machine-3"].ingredient_count = 10
data.raw["item"]["low-density-structure"].stack_size = 50
data.raw["item"]["rocket-control-unit"].stack_size = 50
data.raw["item"]["rocket-fuel"].stack_size = 50

data:extend(
{
{
type = "recipe",
name = "space-science-pack-recipe",
enabled = true,
energy_required = 0.002,
ingredients = {},
result = "space-science-pack",
result_count = 1
},







})
Post Reply

Return to “Modding help”