Jump to content

Recommended Posts

Hey all,

Coming back to KSP for 1.1, I kinda want to give the plugin API a try. I'm interested in fiddling with science experiments and new styles of data collection, but I'm not really sure how to instantiate new pieces of ScienceData. I need to figure that out before I can proceed with fiddling. Here are a couple of things that are leaving me a bit lost:

1) IScienceDataContainer seems to contain the function prototype for recovering data. However, the ModuleScienceExperiment class (which implements it) doesn't actually store data. Am I correct in assuming there's some external, possibly global, storage structure for ScienceData? Where is it located and how do I add to it?

2) By overwriting the location of an existing ScienceData within ModuleScienceExperiment, I can trick the game into recovering my homemade ScienceDatas. However, there are fields within ScienceData that I can't figure out how to populate properly, so it causes problems with the science archives. I can retrieve the base Experiment ID from ModuleScienceExperiment, but ScienceData appears to need something of the format 'ExperimentID@SituationID'. Where do I get the current situation? From the Vessel? What about the container ID?

3) Even if I had the right stuff in my new ScienceData, I'm not certain the new data would show correctly in the science archives. Where is the science recovery process handled? Do I have to register new pieces of ScienceData with some additional class for it to report correctly? What values are displayed in the archive GUI?

4) Where's the science? ScienceData has the number of Mits, but stores no actual science. ScienceExperiments show a base value, but not the current amount collected towards the maximum. How does the game keep track of collected science/data on a per biome, per situation basis?

...Now that I think about it, 3 and 4 are kinda redundant. へ‿(ツ)‿ㄏ

Anyways, I'd appreciate any advice for science plugins in specific and the plugin API in general. Thanks!

 

 

 

 

Link to comment
Share on other sites

Picked this up again today. After an embarrassing amount of hair-pulling, I found the ScienceSubject and ResearchAndDevelopment classes in the KSP API documentation - they were exactly what I needed! Using GetExperimentSubject and SubmitScienceData, I can convert pretty much whatever I want into both Science and a valid R&D Archives entry.

Now I can start building new and more interesting ways to collect science!

...There are still a handful of smaller things I'm unsure about, though. I've been able to work around them, but I'll eventually want to find better solutions:

  • How the heck do you get the vessel's current ExperimentSituations value? This is a complete enigma! I had to reinvent this wheel to get everything else to work. :mad:
  • GetExperimentSubject takes a biome ID as a parameter. What if the experiment is non-biome-specific, like flying Mystery Goo?

 

Link to comment
Share on other sites

  • 1 month later...

So, it's been quite a few weeks since your last post, @The Great Potato, so maybe you have long since figured all this out, but I've been poking at some science lately and have figured out some things, and am scratching my head about others.  Perhaps we can exchange notes?  :)

On 4/9/2016 at 0:53 AM, The Great Potato said:
  • How the heck do you get the vessel's current ExperimentSituations value? This is a complete enigma! I had to reinvent this wheel to get everything else to work. :mad:
  • GetExperimentSubject takes a biome ID as a parameter. What if the experiment is non-biome-specific, like flying Mystery Goo?

Check out the ScienceUtil class, which has some handy static helper methods on it.  In particular:

  • It has "GetExperimentBiome" which will tell you a biome name if you give it a CelestialBody, latitude, and longitude.
  • It has "GetExperimentSituation", which gives you an ExperimentSituations if you give it a Vessel.

Now all I have to do is figure out how to use all the numbers in ScienceSubject.  This page has some very useful descriptions, but I'm still fuzzy on the actual math involved.  Perhaps I need to do some trial-and-error ...experiments.  (no pun intended)

Link to comment
Share on other sites

It's hard to do much to ScienceData that differs much from how standard data is generated. A lot of it is handled internally by R&D so, it can be tricky to try things like manually adjusting the amount of science you get for certain data.

For the Science Subject values check this old thread, aside from the broken formatting I think everything is still valid:

The tricky one is Scientific Value; it handles the science point decay from repeated experiments.

 

Also, regarding the ScienceUtil class, be aware that the KSC biomes work differently. You'll need to check to see if the Vessel.landedAt string is empty, if it isn't the Vessel.GetLandedAtString() string will give you the proper KSC biome name.

 

 

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