Page 1 of 1
Looking for some advice on creating a recipe randomizer mod
Posted: Mon Mar 11, 2019 8:52 pm
by MrValley
I am planning on making a recipe randomizer, using a separate program that pulls the recipes from factorio's
data.raw. I am wondering if there is already a library/tool to convert this kind of format into something I can use in a program, or if I will have to create something from scratch. From what I can tell, converting to Lua script will be relatively simple, since only the recipe will need to be changed.
I'm still in the planning stage and haven't decided on what language to use yet, but any advice in that area would be useful as well. My first thought would be to use Java or Python, as those are my two best languages.
Re: Looking for some advice on creating a recipe randomizer mod
Posted: Mon Mar 11, 2019 9:10 pm
by weaknespase
You correctly noted that it looks like a Lua script and indeed it is a Lua script - you need to set up environment, load it and print results in something neat, maybe XML, probably JSON. Buuuuuut, Lua is pretty nice, Turing complete, multi-paradigm language, so you can use it to make a mod which makes randomization by itself without external dependencies. And it's kind of similar to Python in its dynamic typing nature, so you shouldn't have too hard time using it.
All data in the game accessible and modifiable at last stage of mod initialization, use data-final-fixes.lua to make your changes, or even scrap entire recipe book and make it again.
I don't know where you found data.raw, in my game folder there is much better file structure with separate files for every game aspect. For example, recipe setup files reside in Factorio\data\base\prototypes\recipe - i'm using non-Steam version.
I'd suggest Visual Studio Code, if the need arises for notepad with some Lua tooling support for development.
Re: Looking for some advice on creating a recipe randomizer mod
Posted: Tue Mar 12, 2019 3:05 pm
by MrValley
Expanding on my original questions, would it also be feasible to pull recipes added by other mods and randomize those as well?
Re: Looking for some advice on creating a recipe randomizer mod
Posted: Tue Mar 12, 2019 3:07 pm
by Ranakastrasz
MrValley wrote: ↑Tue Mar 12, 2019 3:05 pm
Expanding on my original questions, would it also be feasible to pull recipes added by other mods and randomize those as well?
Yes. You need to make sure the mod loads last, DataFinalFixes, I think is involved.
After all, other mods can modify other mod's recipes, items, etc. So it is easily possible.
Re: Looking for some advice on creating a recipe randomizer mod
Posted: Sun Apr 28, 2019 9:15 pm
by Qon
If you are making a mod then Lua is the only option, that is what Factorio supports.
You don't have to 'extract' anything since data.raw is accessible to mods.
If you want to make an external tool then you can use a
JSON exporting mod like
Data Exporter to JSON or
Ploppy data exporter.
Or regex the Lua data files from the factorio folder and pretend that they already are almost JSON. I wouldn't recommend this though.