tomf

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

QQXYt8q.png

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
1.4.1
  • Like 34

Share this post


Link to post
Share on other sites

As someone floundering in the morass that is learning to mod KSP, I salute you!

  • Like 1

Share this post


Link to post
Share on other sites

Ahh... GameEvents, nice choice for the image. It looks like I have a lot to update; there seem to be a huge number of new GameEvents since I last looked into it.

  • Like 1

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

This is a wonderful idea, I did some editing in ModuleDeployableSolarPanel and will do more!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

If you experience all the method names missing that is due to you browser caching a template that has changed. Shift-Reload will fix it.

Share this post


Link to post
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?

D.

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

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

  • Like 4

Share this post


Link to post
Share on other sites

I've started dumping my copious notes into it.. Bit by bit, but focused on getting my mods working in 1.1 first.

Share this post


Link to post
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) ?
 

Share this post


Link to post
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.

  • Like 1

Share this post


Link to post
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 :)

@tomf

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.

  • Like 1

Share this post


Link to post
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.

  • Like 1

Share this post


Link to post
Share on other sites

Ok, no problem. Just wanted to make sure I'm not missing anything. :)

Share this post


Link to post
Share on other sites

Great! A place where I can share my notes!

Only problem is.... my tablet's browser can't load the page:(

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now