Json Extractor

by Xyfi

Export all recipes to JSON file, see mod-portal page (https://mods.factorio.com/mods/Xyfi/JsonExtractor) for instructions.

Utilities
7 years ago
0.14
8

i How about dumping the technologies as well? (code included)

7 years ago

I added the following two chunks of code so that the mod could also dump the technologies table. (I hope the forum doesn't screw up the formatting too much.) Feel free to add this to your mod; don't worry about copyright or attribution, in my opinion my additions are too trivial to be copyrightable.

<pre> technologies = function(filename) local filename = filename; if isNullOrEmpty(filename) then filename = "technologies.json"; end local technologies = game.forces[extractorForceName].technologies; writeTechnologiesToJson(filename, technologies) end </pre>

function writeTechnologiesToJson(filename, technologiesUserdata)
technologiesTable = {};
for _, t in pairs(technologiesUserdata) do
local data = {};
data["name"] = t.name;
data["upgrade"] = t.upgrade;
data["ingredients"] = t.research_unit_ingredients;
data["count"] = t.research_unit_count;
data["energy"] = t.research_unit_energy;
data["effects"] = t.effects;
technologiesTable[t.name] = data;
end
game.write_file(filename, JSON:encode_pretty(technologiesTable));
end

7 years ago

Thanks for the code. I have added the technologies option along with an all option to extract everything at once. Also gave you a shoutout on the mod page.

New response