Looking for some advice on creating a recipe randomizer mod

Looking for a mod? Have a review on a mod you'd like to share?
MrValley
Burner Inserter
Burner Inserter
Posts: 10
Joined: Mon Nov 23, 2015 11:44 pm
Contact:

Looking for some advice on creating a recipe randomizer mod

Post 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.
weaknespase
Long Handed Inserter
Long Handed Inserter
Posts: 59
Joined: Sat Mar 24, 2018 8:19 am
Contact:

Re: Looking for some advice on creating a recipe randomizer mod

Post 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.
MrValley
Burner Inserter
Burner Inserter
Posts: 10
Joined: Mon Nov 23, 2015 11:44 pm
Contact:

Re: Looking for some advice on creating a recipe randomizer mod

Post by MrValley »

Expanding on my original questions, would it also be feasible to pull recipes added by other mods and randomize those as well?
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: Looking for some advice on creating a recipe randomizer mod

Post 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.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
Qon
Smart Inserter
Smart Inserter
Posts: 2164
Joined: Thu Mar 17, 2016 6:27 am
Contact:

Re: Looking for some advice on creating a recipe randomizer mod

Post 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.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Post Reply

Return to “Questions, reviews and ratings”