Skip to content

Instantly share code, notes, and snippets.

@morsk
Last active May 15, 2020 03:29
Show Gist options
  • Save morsk/98a555501beb5eea00f4d09821762a30 to your computer and use it in GitHub Desktop.
Save morsk/98a555501beb5eea00f4d09821762a30 to your computer and use it in GitHub Desktop.
Recipe Data Dump [Factorio]
/c
--[[ file appears in Factorio's script-output folder ]]
local OUTPUT_FILE = "recipe_dump.txt"
local function print_table_to_file(t,filename)
local text_format_of_table = serpent.block(t)
game.write_file(filename, text_format_of_table)
end
--[[ https://lua-api.factorio.com/latest/LuaRecipePrototype.html
recipe_prototypes is lazily evaluated, and the table-
dump function can't handle it, so iterate & copy the
parts we want to our own table, first. ]]
local t = {}
for k,v in pairs(game.recipe_prototypes) do
t[k] = {
ingredients = v.ingredients,
products = v.products
}
end
print_table_to_file(t, OUTPUT_FILE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment