I've started creating a mod that will show the total fabrication rate and energy consumption of the selected units. This is to help me estimate whether my economy can handle it when I put some fabricators working, hopefully resulting in a more efficient economy Is there an easy way to get the Fabrication Rate and Energy Consumption as reported in http://planetaryannihilation.gamepedia.com/Commander and for the other units? I've figured out only two hacks for getting that information: (1) Monitor the reported consumption of the selected units (or was it reported only when hovering the mouse over them?) to find out the min/max values of each unit type's production and consumption. Complicated and the values will be known only after building something with the unit type. (2) Read the pages from the wiki with ajax and parse the information from the page. Slow, fragile and might not always be in sync with the real game.
The information from pages like this is based on information you can find as json in PA/media/pa/units I think those files are not directly available to the UI however so you might want to write a program that automatically parses them and prints out a bit of json that you can include in your mod. ... or find out how to access them dunno
If you find out how to access them please let me know I want to read some basic data from units myself.
Refer to the json files directly with the coui:// address instead of using a relative path. It works flawlessly
If memory serves me correct Yarmond ( the person who made pa-db) gave us links to his work that makes these Jsons into easily readable format. Don't think he had posted much more so should be an easy find. Yarmond.database.python.github should do it. There are not so many units which fabricate and their numbers remain a constant so it shouldn't be too hard to compile this list.
I can read those files fine. But has somebody figured out how to know if a Unit/Building is buildable or not ? Cause Megabot for example is not Avatar Factory is not. ...
There's a file (I think it's in the units directory) which is a list of json files for buildable units. EDIT: unit_list.json in PA\media\pa\units
It may be in there, but no factory/constructure unit has the appropriate "buildable_types" value to be able to build it.
Teleporter: https://forums.uberent.com/threads/teleporters.54939/ Unit Cannon: Gunship: Tank Base Commander: Megabot: Plus some old models aren't available any more: Beast Commander: Imperial Commander: Raptor Commander: The remaining unbuildables do not have models.
Based on this info I am about to use this in PA Stats for Alerts filtering, while doing so I've created these functions to parse in data from the unit json files, while tracking the base_specs as well: Code: // parses all units, following unit bases recursively // onComplete is given the finished map of spec => custom piece of data per spec // dataGetter gets the data from the unit json, it expects one parameter: the parsed unit json // datamerger expected two parameters, the data further up the definition tree of the unit and further down // examples see the next 2 functions after this function loadUnitData(onComplete, dataGetter, dataMerger) { var resultTypeMapping = {}; var spawnedUnitCalls = 0; $.getJSON("coui://pa/units/unit_list.json", function(data) { var units = data.units; var finishedAll = false; function readUnitDataFromFile(file, callback) { $.getJSON(file, function(unit) { var freshDataFromUnit = dataGetter(unit); var baseSpec = unit.base_spec; if (baseSpec != undefined) { readUnitDataFromFile("coui://"+baseSpec, function(unitData) { callback(dataMerger(freshDataFromUnit, unitData)); }); } else { if (freshDataFromUnit != undefined) { callback(freshDataFromUnit); } spawnedUnitCalls--; if (spawnedUnitCalls == 0) { onComplete(resultTypeMapping); } } }); } spawnedUnitCalls = units.length; for (var i = 0; i < units.length; i++) { function processUnitPath(unitPath) { readUnitDataFromFile("coui://"+unitPath, function(unitData) { resultTypeMapping[unitPath] = unitData; }); } processUnitPath(units[i]); } }); } //creates a map of all unit specs to their display name function loadUnitNamesMapping(onComplete) { loadUnitData(onComplete, function(unit) { return unit.display_name; }, function (dataUpTheTree, dataDownTheTree) { return dataUpTheTree; // first name encountered is used }); } //creates a map of all unit spec to an array of their type function loadUnitTypeMapping(onComplete) { loadUnitData(onComplete, function(unit) { var unitTypes = unit.unit_types; if (unitTypes != undefined) { for (var u = 0; u < unitTypes.length; u++) { unitTypes[u] = unitTypes[u].replace("UNITTYPE_", ""); } } return unitTypes; }, function(dataUpTheTree, dataDownTheTree) { if (dataUpTheTree == undefined) { dataUpTheTree = []; } if (dataDownTheTree == undefined) { dataDownTheTree = []; } return dataUpTheTree.concat(dataDownTheTree); }); } Maybe somebody finds them helpful or wants to tell me how to do it better Calls look i.e. like this: Code: var pasUnitTypeMapping = {}; loadUnitTypeMapping(function(mapping) { pasUnitTypeMapping = mapping; console.log(mapping); }); loadUnitNamesMapping(function(data) { console.log(data); });