Jump to content

New KSP API Documentation v1.4.1

Recommended Posts

The KSP api has become pretty large now, with over 2000 classes, and as it has no documentation it can be a struggle to find out what anything does.

There have been a couple of attempts to create community driven documentation, but they have all been difficult to update and have stalled.

I present to you the KSP API Wiki

It uses reflection to build up a framework of all the classes, methods, fields etc and then allows you to attach a comment to each.

It also downloads the squad API documentation and includes that.

It is pre-populated with the comments already created in the anatid documentation created by The_Duck


Come if you want to know what the modding communities best guess of what a method does, and if there is a class that you have used that isn't documented, please help out by adding an appropriate comment. No account required.

Huge thanks to @micha for providing working hosting allowing this project to continue.

Edited by tomf
Link to comment
Share on other sites

let's see if we can get it going again. Tried before with the old API that The_Duck had set-up, but with no luck.
I populated some of the new GameEvents based on what I have discovered during the 1.1 pre-release as a tester. Very easy to use.

Link to comment
Share on other sites

7 hours ago, FauserneEist said:

Are you moderating this wiki or can anybody change whatever he wants?

Could you introduce some sort of markdown, to allow us to provide sample code?

Edit: found the documentation in http://docuwiki-kspapi.rhcloud.com/#/about :confused:

Free editing, if it is good enough for Wikipedia on current affairs it ought to be good enough for the api for a computer game.

Changes can be reverted and I could delete all changes by a given ip if vandalism becomes a problem.

6 hours ago, ShotgunNinja said:

I have a suggestion: detect the classes that have some documentation and make them bold in the list on the left.

Have you seen the drop-down that will filter to only show documented classes? I could make them bold too.

Link to comment
Share on other sites

2 hours ago, tomf said:

Have you seen the drop-down that will filter to only show documented classes? I could make them bold too.

It would be great for editors to be able to select "undocumented" as well.

1 hour ago, sarbian said:

I like the idea but I am not a fan of the Class hierarchy. I would prefer seeing all the namespace at the start of the list instead of scrolling to find stuff like KSP.UI

Or the possibility to choose between namespace or class listing.

Link to comment
Share on other sites

I've added some edits, but I wanted to see how stringent we are being on confirming data.

Notably I've edited the BaseAction class with stuff I've discovered on older versions of KSP, but I haven't actually confirmed it recently.

The exact detail in question is that if BaseAction.active == false, the action will not execute even if you call it via code. I confirmed this back in the KSP 0.25/0.90 days and have assumed it is the case even since.

Now, there have been no major changes to the actions system since then, but are we okay with adding possible stale data like that? I did tag the comment that is was an older KSP version, is that sufficient?


Link to comment
Share on other sites

Good question. I am going to say that anything that was true in previous versions is assumed to still be true.

If you find yourself in the unlucky situation where the documentation is no longer up to date, you know what to do.


Link to comment
Share on other sites

15 hours ago, NathanKell said:

I can't really devote time to _doing_ this per se, but if you have questions, poke me.

Thank you and now I'll just be the first one to poke you with something I've ran into with 1.1. :wink:

In GamePersistence there are 3 overloads of the SaveGame Method. I have been using

GamePersistence.SaveGame(string saveFileName, string saveFolder, SaveMode saveMode)

in my plugin, since that had some documentation in the old API doc by The_Duck/Anatid and it worked just fine with KSP 1.0.5

Since KSP 1.1 "quicksaves" created that way behave differently when loaded (using stock load dialog, so no mod involved in loading): Now (in 1.1) the player is put in the Space Center Scene after loading, instead of being put in control of the vessel that was the activeVessel when the quicksave was created.

So the question is: how are the other 2 overloads of SaveGame

SaveGame(Game game, string saveFileName, string saveFolder, SaveMode saveMode)
SaveGame(GameBackup game, string saveFileName, string saveFolder, SaveMode saveMode)

different and when to use which version (quicksave in flight VS a save when in the Space Center) ?

Link to comment
Share on other sites

SaveGame(string, string, SaveMode) merely calls SaveGame(HighLogic.CurrentGame.Updated(), string, string, SaveMode) (or creates CurrentGame if it doesn't exist)

Because calling Updated() sets the start scene to space center. Quicksave instead calls Updated() on CurrentGame to get a Game, then resets that Game's startScene to FLIGHT, and _then_ calls SaveGame(Game, string, string, SaveMode) directly. You should do a similar thing.

Link to comment
Share on other sites

Thank you very much @NathanKell! :)
I've just added your information to the API wiki and will now try to implement it as suggested :)


With a link like href="#/classes/Part?scrollTo=SomeMethodM" we can directly jump to a method in some class. But what if there are multiple overloads for a method? Is there a way to directly link to those as well?
If there is SomeMethod(string) followed by SomeMethod(string, int), then scrollTo=SomeMethodM links to the first one, but how to link to the second one? When I try to add the parentheses and parameter types, the "scrollTo" portion of the link isn't working.

Link to comment
Share on other sites

No, there isn't a way to pick the overload, I wanted to keep the links relatively simple and all the overloads are going to be bunched together anyway so unless someone has written an essay in the comments then all the overloads are going to be on the page anyway. In the the text of the link you can still specify which overload though.

Link to comment
Share on other sites

Is there any kind of error message? What tablet OS is it and which browser are you using? The page use AngularJS which is certainly designed to work on mobile devices. I didn't actually test it on one though.

Link to comment
Share on other sites

10 hours ago, JPLRepo said:

How does the reflection of the latest Modules work? I notice it's not up to date with 1.1.2.

I needed to run the reflecting process on the server. I have run the update now. Purely out of curiosity what did you notice has changed?

Link to comment
Share on other sites

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.

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...