Page 1 of 1

[SOLVED] How to know all recipes

Posted: Sun May 29, 2016 8:32 am
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?

Re: How to know all recipes

Posted: Sun May 29, 2016 8:41 am
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

Re: How to know all recipes

Posted: Sun May 29, 2016 9:04 am
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 :)

Re: How to know all recipes

Posted: Sun May 29, 2016 11:09 am
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.

Re: How to know all recipes

Posted: Sun May 29, 2016 12:12 pm
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.

Re: How to know all recipes

Posted: Tue May 31, 2016 3:00 pm
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?

Re: How to know all recipes

Posted: Tue May 31, 2016 3:08 pm
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.