Jump to content

Configurable Part Module and Resource Interaction


Recommended Posts

I am new to C# and am working on my first plugin. I have a couple questions.

First, how do I make a part module configurable through the part.cfg?

Secondly, how would I do something like the following when the player adjusts a resource slider on a part?


OnResourceChange
{
If (ResourceA + ResourceB > 800)
{
Set ChangedResource = 800 - UnchangedResource
}
}

Thanks!

Link to comment
Share on other sites

For the configuration in the config bit, just give [KSPField] attributes to your fields, and you'll be able to set them in the config file by using this syntax:

myField = someValue

The supported types are int, double, string, and enum I believe.

For the tweakable resource, just add a resource node to your part, they are tweakable by default.

Other than that just check the documentation or take a look at other people's source, those are common things and there's high chances you'll have much faster answers to your questions by digging a little yourself instead of waiting for someone to answer :)

Link to comment
Share on other sites

Yes, but I am trying to make a part that can only hold 800 units TOTAL of multiple resources.

You can't do that with stock, that will need a plugin, and it doesn't seem like it's something that would be a few easy lines of code, since the current system isn't formatted that way.

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