yafc
yafc copied to clipboard
[Feature request] Export json for fully calculated production sheet
It would be useful to be able to store the production sheet with all the calculated amounts. No links, just a list (tree) of recipes with calculated building/ingredient/product counts. The desired use-case is to make a mod for factorio that shows a YAFC production sheet for quick reference and building pipette (something like helmod's overview)
Does this look like the sort of output you'd need?
Exported json
[
{
"recipe": "generator.electricity",
"building": "steam-engine",
"buildingCount": 51.999992,
"modules": []
},
{
"recipe": "boiler.boiler.steam",
"building": "boiler",
"buildingCount": 26,
"modules": []
},
{
"recipe": "fuel-processing",
"building": "fuel-processor",
"buildingCount": 4.68,
"modules": []
},
{
"recipe": "solid-fuel-from-petroleum-gas",
"building": "se-fuel-refinery",
"buildingCount": 0.12018489,
"modules": []
},
{
"recipe": "solid-fuel-from-light-oil",
"building": "se-fuel-refinery",
"buildingCount": 1.3771185,
"modules": [
"effectivity-module",
"effectivity-module",
"speed-module"
]
},
{
"recipe": "coal-liquefaction",
"building": "oil-refinery",
"buildingCount": 2.4036977,
"modules": [
"effectivity-module",
"effectivity-module",
"effectivity-module"
]
},
{
"recipe": "heavy-oil-cracking",
"building": "chemical-plant",
"buildingCount": 1.5624036,
"modules": []
},
{
"recipe": "se-electric-boiling-steam-100",
"building": "se-electric-boiler",
"buildingCount": 0.090806365,
"modules": []
},
{
"recipe": "mining.basic-solid.coal",
"building": "electric-mining-drill",
"buildingCount": 7.2110925,
"modules": []
}
]
(formatting added for readability; the actual output is on a single line)
Note that there are some fake recipes in there. I thought about removing them, but my best guess is that including the number of boilers and miners in the export is worth paying the cost of the pseudo-recipes.
This currently only exports the currently selected page. Is that what you had in mind, or would you rather export all the pages?
Multiple pages
[
{
"name": "Page Title",
"content": [ /* The above array */ ]
},
// More page objects
]
If you want a tree instead of a list, I could do that, probably like this:
With tree support
[
{
"header": {
"recipe": "generator.electricity",
"building": "steam-engine",
"buildingCount": 51.999992,
"modules": []
},
"children": [
{
"header": { /*...*/ },
"children": [ /*...*/ ]
},
{
"header": { /*...*/ },
"children": []
}
]
}
// ...
]
I'd have to think more to actually generate this output, and #158 suggests you'd eventually have to deal with header
being null.
That looks good. IMO a tree version would be better as it preserves the structure defined by the user.
Calculated inputs and outputs for each recipe could also be added.
This currently only exports the currently selected page. Is that what you had in mind, or would you rather export all the pages?
yes, single page
I pushed a branch to my fork; if you're able to compile it, will you check it out and see if it does what you want, please?
Export the calculations from the page settings panel:
I got the treed export working, and expanded the recipe object to this:
The recipe object
{
"recipe": "coal-liquefaction",
"building": "oil-refinery",
"buildingCount": 2.6356473,
"modules": [
"productivity-module-2",
"productivity-module-2"
],
"beacon": null,
"beaconCount": 0,
"beaconModules": [],
"fuel": {
"name": "electricity",
"countPerSecond": 1.808054156470182
},
"inputs": [
{
"name": "coal",
"countPerSecond": 4.480600218359827
},
{
"name": "heavy-oil",
"countPerSecond": 11.201500545899567
},
{
"name": "steam@100",
"countPerSecond": 22.403001091799133
}
],
"outputs": [
{
"name": "heavy-oil",
"countPerSecond": 42.07283673408411
},
{
"name": "light-oil",
"countPerSecond": 9.4988728047655
},
{
"name": "petroleum-gas",
"countPerSecond": 4.74943640238275
}
]
}
The 'electricity' fuel is measured in MJ, because that's how YAFC does it internally.
Works, does what it should. Thanks.
One thing I would change would to match the behaviour of saving the export string and store in the clipboard instead of a file.
edit. also, it throws an exception when closing the save path dialog (aborting)
I'm not convinced exactly matching the Share feature is the correct behavior. Is it easy to decode YAFC's shared strings in a mod? If it is, I can match Share exactly, but if not, I'll use gzip instead of deflate, to match Helmod's strings.
The format is fine (I also don't like the compression layer), I'm just thinking about the clipboard > file