It looks like you're new here. If you want to get involved, click one of these buttons!
I am trying to write a plugin that will load a text file with a list of bodies along with political affiliations, and proceed to find said bodies in the currently loaded sector and change their PoliticalAffiliation property as per the file.
My problem is what key to use to locate the desired body object in the sector.
The Sector.GetSystem(integer) method needs an int argument, does this mean that for each change I have to iterate through GetSystem(), check the Body.Name property (or something) to find a match, then change the Body.PoliticalAffiliation property as desired? There does not seem to be a way to look up bodies by their UABI, not that the UABI is easily accessible.
I could export the entire sector into an XML file with XMLExport.AstroScript, write a Python program to parse it and forcibly change the political affiliation, then import it into AstroSynthesis via XMLImport.AstroScript. But that just seems to be a round about way to perform the task.
What I am trying to do is create a map with multiple interstellar empires, with ownership of each system defined by which "empire center" is the closest.
http://www.projectrho.com/public_html/rocket/stellarempire.php#ascubemap
Comments
Every body has an IDString property, which is the UABI. This looks like its missing in the docs. Its actually a property of an ancestor class, which is probably why it was missed in the docs.
For ex:
There's no lookup by UABI, so you'd have to iterate each body (and their children if not just working with root bodies).
Alternatively, you can write to the AstroDB file directly using Python, as the AstroDB file is an SQLite database. You can then use SQL to make the changes to the database.
for ex:
Here's a sample using recursion to find a body by UABI. This was a quick hack, so may not be the most efficient.
Thank you! I'll give it a go.