Page 1 of 1

Command line flag (dump-defines) to dump prototype defines

Posted: Tue Mar 14, 2023 3:30 pm
by Redruin
What?
1.1.77's patch notes add several data-extraction oriented command line options:
  • Added a command line flag (dump-data) to dump data-raw to the script output folder as json.
  • Added a command line flag (dump-icon-sprites) to dump prototype icons to the script output folder.
  • Added a command line flag (dump-prototype-locale) to dump prototype locale to the script output folder.
My proposal is to add another option (dump-defines) that would dump either a Lua or JSON table of the API defines to script output.
Why?
In order for the Factorio data-stage of the load process to take place, this table must exist in the Lua context under the name `defines`. This is important when emulating this load process (a la my module draftsman), but the data is not provided in Wube's official factorio-data repo, nor the official API website. Instead, it has to be manually extracted from the game (for each game version) with the command:

Code: Select all

/c game.write_file("defines.lua", "defines = " .. serpent.block(defines, {indent="    "}))
By adding a command line option for this it potentially opens up the option for a completely automated workflow where all information needed for the load-process can be extracted automatically on Factorio version bump.
Alternatively:
It would also be perfectly fine if this defines file was included in some way in the "factorio-data" repo, which would make this option unnecessary. But I imagine that such data actually lies in C++ code (which will have to be converted every version anyway) and introducing such a file might create complications.

Re: Command line flag (dump-defines) to dump prototype defines

Posted: Tue Mar 14, 2023 4:30 pm
by Xorimuth
You can use the existing command line arguments to load a specific directory of mods (which would have a mod that runs your defines dump command) and to load into a specific save so that the mod is loaded and can run its command.