Jump to content

Floundering: doing science around specific celestial bodies


Recommended Posts

Hello folks. I'm very new to the coding scene straight from modeling, and I'm just doing some tests to help me with a future "Solar Science" mod, intent on at least partly reproducing the instruments on the SoHO spacecraft.

Anyways, being a man of very little coding ability, I found the below script from the user Ethernet here, and I wanted to change it to suit my needs. My goal is to seclude my experiment to only being usable around Kerbol, and if possible add something about only using it when below a certain height from it. Ideally with a couple string changes this could be reused for any specific celestial body, but that's besides the point.

Under the C# is how it is in the part.cfg file currently, which isn't showing any signs of working. I also included the (working) animation module above it in case there's any connection, since I want the test object to play the animation, run the experiment (if it's over the sun, otherwise display the other result), and then, upon activating the action group, retract.

So, what do I do from here? What format does the plugin have to be, and where do I put it? What edits to the code must be made for this to function?

public class SolarExperiment : ModuleScienceExperiment

public bool checkBody() {
if(vessel.mainBody.name == "Sun")
return true;
ScreenMessages.PostScreenMessage("This experiment only operates around Kerbol!", 3, ScreenMessageStyle.UPPER_CENTER);
return false;
}

new public void DeployExperiment() {
if(checkBody())
base.DeployExperiment();
}

new public void DeployAction(KSPActionParam p) {
if(checkBody())
base.DeployAction(p);

Part Config:

MODULE

{

name = ModuleAnimateGeneric

animationName = expandDong

startEventGUIName = Deploy

endEventGUIName = Retract

}

MODULE

{

name = SolarExperiment

experimentID = HMI

experimentActionName = Record Images

resetActionName = Delete System 32 lol

useStaging = False

useActionGroups = True

hideUIwhenUnavailable = False

xmitDataScalar = 0.5

dataIsCollectable = True

collectActionName = Take Data

interactionRange = 1.2

rerunnable = True

}

Link to comment
Share on other sites

How is it 'not working'? Part doesn't show up in game? Science action doesn't show up at all? Science action works everywhere?

I apologize, I should have specified. The part does show up in the game, and the Animation plays when you activate the action group. When testing the part with ModuleScienceExperiment rather than this, it works fine, alibi separate from the animation action group.

However, using SolarScience instead shows only the animation action group in game, leading me to believe that module is not being recognized as even existing and therefore just nixed from the game. Currently the plugin is only a .cs file in Gamedata>MyModFolder>Plugins, and I think I have to end up with a .dll instead, but I don't know how to do that, nor do I know if it's necessary.

Link to comment
Share on other sites

No probs.

Yes the problem here is that you don't have a dll. C# code - like in the .cs file above - has to be 'compiled' in order to be executed. If you look through your KSP log you'll probably find a line like 'Module SolarExperiment doesn't exist' - try opening it in a text editor and searching.

This page mentions some of what you need to do to start making plugins - look at the 'Creating Plugins' section. Each of the entries in the IDE table is clickable and will teach you how to set up that IDE to do KSP modding. I personally use visual studio. You might find looking up how-do-i-start-programming-in-C# tutorials useful.

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