Jump to content

Two questions


wizzlebippi

Recommended Posts

1) It's all done with KSPField


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using ObjectTools;


namespace MyProject
{
public class SomePartModule : PartModule
{
[KSPField(isPersistant = false)]
public int someInteger;
[KSPField(isPersistant = false)]
public int someInteger2 = 1;
[KSPField(isPersistant = true)]
public float someFloat = 1;
//more stuff here
}// end class
}//end namespace

In you config, you could have:



MODULE
{
name = SomePartModule
someInteger = 2
someInteger2 = -1
someFloat = 1.25
}

The values will be read out of the config and will overide what they are set to in the code. The variables must be declared public (C# defaults to private) for this to work. Notice the isPersistent attribute can be, and is, applied to the float in this case. This means that if the value is modified by the code in-game, the value will be stored in the persistence file for that instance of that part, and will be read back upon loading that save. HTH :)

That is assuming I've interpreted your question correctly..

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