5

I'm currently making a tourist planner for KSP which reads in the persistent.sfs which tourist want to do what on which planet . Here's a preview.

tourism planner

The problem is that although science has the whole body name, tourist contracts use a targetBody to tell which planet

For example here is a tourist contract in the savefile

PARAM
            {
                name = KerbalTourParameter
                state = Incomplete
                disableOnStateChange = False
                allowPartialFailure = True
                values = 219375,0,0,0,0
                kerbalName = Ludves Kerman
                kerbalGender = Male
                PARAM
                {
                    name = KerbalDestinationParameter
                    state = Incomplete
                    values = 24375,0,0,0,0
                    targetBody = 5
                    targetType = Orbit
                    kerbalName = Ludves Kerman
                }
                PARAM
                {
                    name = KerbalDestinationParameter
                    state = Incomplete
                    values = 24375,0,0,0,0
                    targetBody = 0
                    targetType = Orbit
                    kerbalName = Ludves Kerman
                }
                PARAM
                {
                    name = KerbalDestinationParameter
                    state = Incomplete
                    values = 24375,0,0,0,0
                    targetBody = 2
                    targetType = Flyby
                    kerbalName = Ludves Kerman
                }
            }

(as you can see on my screenshot, Ludves wants to Orbit the Sun (0), Orbit Eve (5) and flyby the Mun (2))

And here is a science found

Science
    {
        id = mysteryGoo@KerbinSrfLandedLaunchPad
        title = Observation de la glairine™ mystérieuse d’Aire de lancement
        dsc = 1
        scv = 0.0122894989
        sbv = 0.300000012
        sci = 3.85207105
        cap = 3.9000001
    }
  • Do you know where I can find the IDs of all bodies in KSP instead of just doing every single mission?
  • Are they the same between each save game?

For the moment I have found :

Sun : 0
Kerbin : 1
Mun : 2
Minmus : 3
Duna : 6 (you see the number begin to become unsorted...)
Ike : 7
Eve : 5

Thanks!

3
  • Have you looked through the wiki for the game? That'd be the first place I'd check.
    – MBraedley
    Dec 22 '18 at 14:13
  • I didn't find anything on the wiki (I was hoping to find this on every body page) did you? I even looked at the code after several google searches but no result... Be sure I'll update the wiki when I have this information
    – Goufalite
    Dec 22 '18 at 15:09
  • I found it randomly on the wiki, but there is no source or analysis : wiki.kerbalspaceprogram.com/wiki/Orbit#Reference_code
    – Goufalite
    Jan 5 '19 at 15:51
1

At least one way to observe this numbering in-game is to press Alt+F12 to open the cheat menu, select the "Set Orbit" pane and scroll through the list of available celestial bodies. They seem to be presented in exactly the order given by the numbers you list, i.e. Sun → Kerbin → Mun → Minmus → etc.

I believe the numbering itself comes from the order in which the bodies are stored internally in the FlightGlobals.Bodies list (and I suspect it historically more or less reflects the order in which the various bodies were added to the game during its development). If you're writing a mod, you should be able to access a celestial body by its ID number simply by using the number as an index into this list. Conversely, every CelestialBody object has a FlightGlobalsIndex property that gives its index in the list.

I'm not sure if there's any convenient way to obtain this numbering directly from a save file. For a stock KSP install, it should always be the same so you could just hardcode it, but mods that add new celestial bodies e.g. via Kopernicus can presumably mix it up.

1
  • In fact it's just an external tool that reads the persistent.sfs so I won't have access to the code... Good finding of the debug list though
    – Goufalite
    Dec 29 '18 at 20:54
1

A reddit user sent a probe to all bodies and used the REF line of the orbit caracteristics:

0 - Sun
4 - Moho
5 - Eve
13 - Gilly
1 - Kerbin
2 - Mun
3 - Minmus
6 - Duna
7 - Ike
15 - Dres
8 - Jool
9 - Laythe
10 - Vall
12 - Tylo
11 - Bop
14 - Pol
16 - Eeloo
  • The values match those I have already found
  • It was a fresh new game

So the IDs are the same between saves

1
  • This list is still experimental. I'll wait until someone can find an "official" list before accepting this answer
    – Goufalite
    Dec 29 '18 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.