Jump to content

EditorLogic.SortedShipList, EditorLogic.fetch.ship.parts etc. which one to use?


Recommended Posts

I just started developing a simple plugin and I wanted to get all the parts of a vessel in the editor. After digging through some code bits from Mechjeb, AlternateResourcePanel, RCSBuildAid and others (thanks to the developers, having code to look at how to do things helps a lot!) I found several Methods to get all the Parts of the current vessel.

First I used EditorLogic.startPod and went through all the children of the Part (recursively) which worked fine. Then I found http://anatid.github.io/XML-Documentation-for-the-KSP-API/annotated.html which seems to be the only documentation with at least some comments...

So after finding EditorLogic.SortedShipList, EditorLogic.fetch.ship.parts I'm wondering which one should be used (or maybe which one is faster)? They seem to be both working, with the SortedShipList I don't have to get a instance of EditorLogic, get the ShipConstruct and then the parts so I think this should be the faster/better one!? (except that the name SortedShipList doesn't make sense...)

So the question is: how should I get all the parts of the current vessel in the editor?

And a second question: is there any documentation of the KSP classes I missed? I know I can use the Object Browser in Visual Studio to browse the Assembly-Csharp but there ain't no documentation...

Edited by SMILIE
Link to comment
Share on other sites

Unfortunately, documentation is sparse. The best documentation I am currently aware of is at http://anatid.github.io/XML-Documentation-for-the-KSP-API/

On your question about ship parts, EditorLogic.SortedShipList is what I use and it is exactly what I expect, a list of all parts.

Note I believe it is only parts actually attached, I don't think parts not attached (so the semi-transparent grayed out state) are in that list. (Not actually tested however.)

I have never used EditorLogic.fetch.ship.parts, but I would assume it is the same. I have noticed that the same information is quite often available in two (or more) places in the API available to us.

D.

Link to comment
Share on other sites

Okay thanks!

I actually thought about documenting the stuff I come across in the official wiki and as I'm struggling to find more and more information I need I'm getting quite sure I will do this.

I'll maybe open another thread and start by creating a template for class/function documentation on the wiki...

(something like the Garrysmod wiki should be the outcome, this one is quite well documented, often with examples!)

Edited by SMILIE
Link to comment
Share on other sites

Excellent, we need more people documenting stuff. Allow me to suggest contributing to my Github project instead of the wiki. There are instructions for contributing at that link; a number of people have contributed to the project so far. The web documentation you linked in your OP comes from my project. My project also results in XML documentation that can be read by your IDE. I tried documenting things on the wiki for a while but wikis are not designed for documenting source code. Proper tools like Doxygen (which generates the web docs you linked) are much easier to use and generate much nicer pages.

Edited by The_Duck
Link to comment
Share on other sites

Okay great, I already thought about doing this! :)

If you already tried to do it in the wiki and it didn't work, I will contribute to your project! It would be cool if one of the moderators could add it to one of the sticky posts, or did I miss it and it is already there?

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...