How to generate items/recipes from existing items?

Place to get help with not working mods / modding interface.
Ch4rl1e
Burner Inserter
Burner Inserter
Posts: 8
Joined: Thu Aug 13, 2020 5:48 pm
Contact:

How to generate items/recipes from existing items?

Post by Ch4rl1e »

Hello!

So I want to iterate through all the barrels, which I know the game itself generates from all valid fluids, in order to create a new item based on each, and a corresponding recipe.

I found through looking at other mods that one can iterate over barrels as such in data-updates.lua:

Code: Select all

for _,r in pairs(data.raw.recipe) do
	if r.subgroup=="fill-barrel" then
		r.energy_required = TIME_FIL
		r.ingredients[1].amount = CAP
	elseif r.subgroup=="empty-barrel" then
		r.energy_required = TIME_EMP
		r.results[1].amount = CAP
	end
end
which is a starting point, but this is just for modifying values about the existing barrels, not creating new items/recipes from them.

I want to use the name of the barrel within the name of the item as well, and I am then unsure on how you'd go about generating locales for all of the items as well. In theory this should support any mod fluids as well as at this point they'll have been barrellised by the base game already.

Any ideas on how to do this? I understand you can add recipes and items with data:extend() which I've already done successfully but doing this "procedurally" is confusing.

The idea is silly and is effectively just compression, making "pallet of {barrel name}" with 1 wood and 4 barrels. Would have a reverse recipe too of course. Image
It's more just practice than anything else.

Thanks
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: How to generate items/recipes from existing items?

Post by darkfrei »

gogglebot wrote: Thu Aug 13, 2020 6:01 pm I want to use the name of the barrel within the name of the item as well, and I am then unsure on how you'd go about generating locales for all of the items as well. In theory this should support any mod fluids as well as at this point they'll have been barrellised by the base game already.
See how it was done in the barreled fluids:
localised_name
localised_name
2020-08-21T13_23_04.png (8.54 KiB) Viewed 1260 times
item locale
item locale
2020-08-21T13_26_47-_D__Factorio_0.18_data_base_locale_en_base.cfg.png (1.72 KiB) Viewed 1260 times
The same for recipe:
2020-08-21T13_30_59-empty.png
2020-08-21T13_30_59-empty.png (10.54 KiB) Viewed 1258 times
2020-08-21T13_30_32-fill.png
2020-08-21T13_30_32-fill.png (9.22 KiB) Viewed 1258 times
recipe locale
recipe locale
2020-08-21T13_28_20-recipe-locale.png (6.54 KiB) Viewed 1259 times
gogglebot wrote: Thu Aug 13, 2020 6:01 pm Any ideas on how to do this? I understand you can add recipes and items with data:extend() which I've already done successfully but doing this "procedurally" is confusing.
See the code of https://mods.factorio.com/mod/BottledFluids, it's the same as barreling, but bottling and the script is much simpler (I think).
gogglebot wrote: Thu Aug 13, 2020 6:01 pm The idea is silly and is effectively just compression, making "pallet of {barrel name}" with 1 wood and 4 barrels. Would have a reverse recipe too of course. Image
It's more just practice than anything else.
1. You are need the list of barreled fluids;
You can just search by data.raw.item for them; it can be empty barrel too!

2. You are need the palette, item and recipe for it.

3. The main cycle, where you make prototypes for new barrels-on-palette items, recipes for pack- and unpacking and icons for them. One set for every element from point 1.
Post Reply

Return to “Modding help”