Jump to content

How to find current biome? (including "LaunchPad" etc.) [Answered]


Recommended Posts

So, I'm trying to figure out "what biome is the ship in".  Simple, right?

So far, I've found two ways:

  • ScienceUtil.GetExperimentBiome
  • ResourceUtilities.GetBiome

...and they both work... mostly.

However, they appear to be clueless about the various mini-biomes around KSC.  For example, if I'm sitting on the launch pad and query either of those mechanisms, they'll simply say "Shores".

How do I get the actual science biome of the current ship position?  In other words, "If I were to take a science measurement right now, what biome would it say", including the micro-KSC biomes?

Link to comment
Share on other sites

Oh!  So that's what Vessel.landedAt is for.

Okay, well, nice to know that not everything has to be hard.  :)

Thank you for the answer!  Very easy, yes, but it sure wasn't very discoverable (by me, at least).  Would have taken me forever to find that on my own.  Much obliged.

-------------

[EDIT]  ...Okay, I spoke too soon.  It's still not quite what I need.

 

1 hour ago, sarbian said:

The code in question basically says, "use Vessel.landedAt if it's there, otherwise use the current biome".

public string CurrentRawBiome()
{
    if (vessel.landedAt != string.Empty)
        return vessel.landedAt;
    string biome = ScienceUtil.GetExperimentBiome(mainBody, vessel.latitude, vessel.longitude);
    return "" + biome;
}

...The problem is, it doesn't seem to match what I need.  If I do this on the launchpad at KSC, for example, landedAt is KSC_LaunchPad_Platform, whereas what I actually need is just LaunchPad.

What I mean by "what I need":  I need the biome name that ends up in science subject IDs.  For example, if I take a gravimeter reading on the launch pad at KSC, the subject ID that it ends up with is:

gravityScan@KerbinSrfLandedLaunchPad

...It's pretty clear that the way the game constructs a subject ID is:  experiment ID + @ + body + situation + biome

...so the "biome" that I need, here is just plain "LaunchPad".

Nor can I just do something programmatic, like "parse out the first word after "KSC_".  For example, the ground just east of the launchpad platform gives a landedAt value of KSC_Pad_Grounds, but the resulting science subject ID is still using a biome string of LaunchPad.

I suppose I could try just driving all over KSC with the debugger and seeing what landedAt gets set to, and then build a dictionary (e.g. "if landedAt is 'KSC_LaunchPad_Platform', then the biome is 'LaunchPad', etc.) to do the translation.  But that seems really hacky, tedious, and error-prone (I'm likely to miss stuff) ... surely there must be a better way?

Link to comment
Share on other sites

...Okay, was able to find the answer.

It turns out that there's a static function Vessel.GetLandedAtString.  Pass in the value of Vessel.landedAt, and it returns the string that gets used in science subject IDs.

So the algorithm is basically,

  1. check vessel.landedAt to see if there's a string there
  2. if there is, the answer is Vessel.GetLandedAtString(vessel.landedAt)
  3. if there isn't, use the other biome-determining functions

 

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