Recipe change not put into effect

Place to get help with not working mods / modding interface.
davemcdave
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Recipe change not put into effect

Post by davemcdave »

I'm trying to change vanilla recipes using data-final-fixes.lua but some of the recipes show up unchanged in game.
i've tried in data-updates.lua with the same result.
i cant see any pattern to why these recipes.
is there a common rookie mistake that could cause this?
if its something complex then i can work around by creating new recipes for them instead, itd be nice to understand the problem though.

heres some of the failing recipes:

Code: Select all

data.raw.recipe["express-transport-belt"].ingredients = {{"transport-belt",1},{"copper-plate",6},{type="fluid", name="lubricant", amount=5}}
data.raw.recipe["burner-mining-drill"].ingredients = {{"iron-gear-wheel",3},{"raw-wood",3}}
data.raw.recipe["electric-mining-drill"].ingredients = {{"burner-mining-drill",4},{"electronic-circuit",4}}
data.raw.recipe["assembling-machine-2"].ingredients = {{"assembling-machine-1",1},{"electronic-circuit",3},{"iron-gear-wheel",5}}
data.raw.recipe["steel-plate"].ingredients = {{type="fluid", name="crude-oil", amount=30},{"iron-ore",3}}
	data.raw.recipe["steel-plate"].category = "crafting-with-fluid"
data.raw.recipe["sulfuric-acid"].ingredients = {{type="fluid", name="sugar-syrup", amount=10}}
data.raw.recipe["electronic-circuit"].ingredients = {{"copper-plate",1},{"iron-ore",1}}
data.raw.recipe["advanced-circuit"].ingredients = {{"electronic-circuit",1},{"repair-pack",1}}
and some of the changes that are working fine:

Code: Select all

data.raw.recipe["fast-transport-belt"].ingredients = {{"transport-belt",2},{"copper-cable",7},{"express-transport-belt",1}}	
data.raw.recipe["express-underground-belt"].ingredients = {{"fast-underground-belt",2},{"express-transport-belt",8},{"iron-gear-wheel",8}}
	data.raw.recipe["express-underground-belt"].category = "crafting"
data.raw.recipe["pumpjack"].ingredients = {{"electronic-circuit",5},{"iron-gear-wheel",5},{"pipe",5},{"offshore-pump",1}}
data.raw.recipe["assembling-machine-1"].ingredients = {{"stone",10},{"raw-wood",2}}
data.raw.recipe["assembling-machine-3"].ingredients = {{"electronic-circuit",5},{"iron-gear-wheel",5},{"pipe",5},{"steel-plate",5}}
data.raw.recipe["engine-unit"].ingredients = {{"stone",1},{"iron-plate",1}}
data.raw.recipe["electric-engine-unit"].ingredients = {{"iron-ore",3},{type="fluid", name="crude-oil", amount=30},{type="fluid", name="lubricant", amount=10}}
MostlyNumbers
Inserter
Inserter
Posts: 26
Joined: Fri Apr 13, 2018 10:07 pm
Contact:

Re: Recipe change not put into effect

Post by MostlyNumbers »

You've identified some of the items that get modified under expensive mode. You have to indicate if this is the normal or expensive recipe:

Code: Select all

data.raw.recipe["my-target-recipe"].normal.ingredients = {something}
(For those items only)
Kynaro
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu May 18, 2017 2:48 pm
Contact:

Re: Recipe change not put into effect

Post by Kynaro »

I'm having a similar issue, but with the error:
Error while loading recipe prototype "copper-plate" (recipe): Difficulty normal: Key "name" not found in property tree at ROOT.recipe.copper-plate.ingredients[0]

Code: Select all

     if item["ingredients"] then
		ingredientItems = item["ingredients"]
	elseif item["normal"] and item["normal"]["ingredients"] then
		ingredientItems = item["normal"]["ingredients"]
	end
	
	if ingredientItems ~= nil then
		for _, ingredient in pairs(ingredientItems) do
			
			local ingredientName = ingredient[1] or ingredient["name"]
			local ingredientAmount = ingredient[2] or ingredient["amount"]
			
			if ingredientAmount ~= nil and count_reduction ~= 0 then
				ingredient.amount = math.ceil(ingredientAmount / count_reduction)
				log(item.name .. " REDUCED " .. ingredientName .. " COUNT TO " .. ingredient.amount)
			end
			
		end
	end
I'm not sure what to change at this point; I've tried a few different methods.
davemcdave
Burner Inserter
Burner Inserter
Posts: 10
Joined: Sun Jun 10, 2018 1:24 pm
Contact:

Re: Recipe change not put into effect

Post by davemcdave »

MostlyNumbers wrote:You've identified some of the items that get modified under expensive mode. You have to indicate if this is the normal or expensive recipe:

Code: Select all

data.raw.recipe["my-target-recipe"].normal.ingredients = {something}
(For those items only)
that fixed it! tyvm :)
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Recipe change not put into effect

Post by eradicator »

Kynaro wrote:I'm having a similar issue, but with the error:
Error while loading recipe prototype "copper-plate" (recipe): Difficulty normal: Key "name" not found in property tree at ROOT.recipe.copper-plate.ingredients[0]
Quick guess: You're modifying ingredients to have a mixed (=broken) format. Something like:

Code: Select all

ingredients = {{type='item',name='copper-plate',amount=1}} --ok
ingredients = {{'copper-plate',1}} --ok
ingredients = {{'copper-plate',amount=1}} --broken
Solution: Replace the whole subtable instead of editing it in-place.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: Recipe change not put into effect

Post by darkfrei »

Easy correction for all ingredient fomats:

Code: Select all

local name = ingredient.name or ingredient[1] 
local amount = ingredient.amount or ingredient[2] 
local type = ingredient.type or "item"
ingredient = {name=name, amount=amount, type=type}
Kynaro
Burner Inserter
Burner Inserter
Posts: 12
Joined: Thu May 18, 2017 2:48 pm
Contact:

Re: Recipe change not put into effect

Post by Kynaro »

Thanks dudes, that was it!

Code: Select all

if ingredientItems ~= nil then
		for i, ingredient in ipairs(ingredientItems) do
			
			local ingredientName = ingredient[1] or ingredient["name"]
			local ingredientAmount = ingredient[2] or ingredient["amount"]
			local ingredientType = ingredient.type or "item"
			
			
			if ingredientAmount ~= nil and count_reduction ~= 0 then
				ingredientAmount = math.ceil(ingredientAmount / count_reduction)
				
				ingredient = {name = ingredientName, amount = ingredientAmount, type = ingredientType}
			
				log(item.name .. " REDUCED " .. ingredientName .. " COUNT TO " .. ingredient.amount)
			end
			
			ingredientItems[i] = ingredient
			
		end
	end
Post Reply

Return to “Modding help”