Jump to content

How do I setup parameters for a module on a part


Recommended Posts

I want to have parameters in my module on a part. I have no idea how to access them from the C# plugin.

MODULE
{
name = resourceScienceModule
resourceName=ElectricCharge
resourceAmount=10.0
experimentID = mysteryGoo
amount=10;

experimentActionName = Observe Mystery Goo
resetActionName = Reset Goo Canister

useStaging = False
useActionGroups = false
hideUIwhenUnavailable = false

xmitDataScalar = 0.3

FxModules = 0

dataIsCollectable = True
collectActionName = Collect Data
interactionRange = 1.2
}

The parameters I want to read are the first 4. How do I read the parameters ?

Link to comment
Share on other sites

You need to add KSPFields in your PartModule class.

Let me point you to an excerpt from my code (read: I'm too lazy to type right now): you need to mark the fields you want to load with the KSPField attribute. They must have the same exact name you gave them in the cfg file and they will be loaded automatically when the module is restored from the save file. Also, you can't use double, you must use float instead (double fields are not supported by KSPField for some reason).

Alternatively, you can always load them manually during OnLoad.

Link to comment
Share on other sites

Thanks. Now I just need to be able to create science data.

Edit update: I managed to override the Deploy method for the scienceExperiment module so now it will spend a resource to deploy the experiment.

The only problem is I can't find what is run when resetting the experiment so I can't refund the resources spent on it.

Edited by michaelhester07
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...