[SOLVED] How to know all recipes

Place to get help with not working mods / modding interface.
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

[SOLVED] How to know all recipes

Post by DRY411S »

I'm writing a recycling mod that reverses recipes, so I need to know what all the recipes are in a running game.

How can my mod know when other mods have added recipes? Or, how can I make my mod load last so I can read all the recipes, knowing that no more will be added?
Last edited by DRY411S on Wed Jun 01, 2016 7:00 pm, edited 1 time in total.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: How to know all recipes

Post by steinio »

Well as i know all receipes are listed in game.force.receipes
http://lua-api.factorio.com/0.12.34/Lua ... ml#recipes

Greetings steinio
Image

Transport Belt Repair Man

View unread Posts
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: How to know all recipes

Post by DRY411S »

Thanks.

But how do I know that that is fully populated when I read it, and all the other mods recipes have been added?

* Sorry if that's a noob modder question, because I am a noob modder :)
User avatar
ArderBlackard
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Thu May 05, 2016 12:41 pm
Contact:

Re: How to know all recipes

Post by ArderBlackard »

There are three iterations of prototypes definition for all the mods: first 'data.lua' are run for all mods (if present), then 'data-updates.lua' scripts are run, then the same is done for 'data-fnal-fixes.lua'. Most of the mods define their prototypes in 'data.lua' files. You probably should consider using 'data-final-fixes.lua' in your mod - it's very likely all other recipes will be defined at the time it will be loading.

You may read about more details on wiki: https://wiki.factorio.com/index.php?tit ... _Lifecycle.
Gib dich hin bis du Glück bist
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: How to know all recipes

Post by DRY411S »

ArderBlackard wrote:There are three iterations of prototypes definition for all the mods: first 'data.lua' are run for all mods (if present), then 'data-updates.lua' scripts are run, then the same is done for 'data-fnal-fixes.lua'. Most of the mods define their prototypes in 'data.lua' files. You probably should consider using 'data-final-fixes.lua' in your mod - it's very likely all other recipes will be defined at the time it will be loading.

You may read about more details on wiki: https://wiki.factorio.com/index.php?tit ... _Lifecycle.
That's an interesting and useful link, thank you.

I'm starting to think now that I will use the on_research_finished event. Each recycling recipe will only become enabled when the equivalent crafting recipe is unlocked by research, and my mod only starts working when Automation has been researched, so I can initialise all the enabled recipes on the event when LuaTechnology.name = "automation", and then add new recycling recipes as the other research progresses.
User avatar
DRY411S
Filter Inserter
Filter Inserter
Posts: 736
Joined: Sun Mar 13, 2016 9:48 am
Contact:

Re: How to know all recipes

Post by DRY411S »

To avoid starting another topic about recipes...

Is it possible to have more than one recipe with the same name, but perhaps other different elements like ingredients categories or results?

Or is a recipe 'name' unique, like a primary key on a database table?
User avatar
ArderBlackard
Long Handed Inserter
Long Handed Inserter
Posts: 74
Joined: Thu May 05, 2016 12:41 pm
Contact:

Re: How to know all recipes

Post by ArderBlackard »

DRY411S wrote:Or is a recipe 'name' unique, like a primary key on a database table?
Exactly. A recipe name should be unique.
Gib dich hin bis du Glück bist
Post Reply

Return to “Modding help”