Jump to content

[Closed] back to game


Recommended Posts

hello !

I test this in a pluggin :

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Spring-Tweak"), UI_FloatRange(minValue = 0.0f, maxValue = 40.0f, stepIncrement = 0.5f)]
public float MassSlider = 0.0f;

I have some questions ?

  1. It's possible to have negative value for minValue and maxValue ?
  2. It's possible to drive minValue or maxValue by variable like : minValue = rangeInf ?
  3. Is that code need to be rewrite, on each segment in pluggin (like onStart or onUpdate), to work properly ?

  • My problem :

In sph the range work : I have (by right click) my range defined between 0 and 40.

but in game, with plane is on runway, the range is modified to -20 to 20 :confused:.

MassSlider is only declared one time by the code above, so I have no idea why Ksp change the range to -20 20 !

And other thing :

For monodevelopp export , they particular thing to do or I keep just the default export setup ?

voilà merci thank you

steph

Edited by stephm
Link to comment
Share on other sites

1. Yes.

2. Possible, yes, but it would be pretty hard and would involve reflection, and you don't want to do that. So personally I class this as a "no", you can't really modify those values.

3. No.

For your problem, we're going to need more info (by that I mean more code and logs), because on a first look I don't see why it would do that.

Link to comment
Share on other sites

hello !

Oups yes it's true it's the same thing for bug in KSP need log and info !

// Just to see the effect in game by tweaking the wheelcollider's parameter

using UnityEngine;

using System;

using KSP.IO;namespace SmallGearBayAR

{

public class SprinGSetup : PartModule

{

// -- Init Plugg on first start --

private bool SpringInit = false;

// ------ Mass Parameter ------

[KSPField(isPersistant = true, guiActive =true, guiActiveEditor = true, guiName ="Vessel's Mass Test", guiFormat = "F1")]

public float TotalMass; //vessel Mass

public float SpringMass = 0f; //Spring Force

// ------ WheelCollider Spring Parameter ------

private WheelCollider MyWheelCol;

private WheelCollider WheelColContainer;

private JointSpring SuspParameter; // spring parameters

//private float SuspDist; // for further test

//----

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Spring-Tweak"), UI_FloatRange(minValue = 0.0f, maxValue = 40.0f, stepIncrement = 0.5f)]

public float MassSlider = 0.0f;

public override void OnStart(StartState state)

{

base.OnStart(state);

if (!SpringInit) InitSLiderSpring();

}

public override void OnUpdate ()

{

base.OnUpdate();

float Test = SpringMass + MassSlider;

if ((HighLogic.LoadedSceneIsFlight) && (SuspParameter.spring != Test))

{

// adjust + tweak

TweakSpring(MassSlider);

}

}

// ---- save load methodes ----

/*

public override void OnSave(ConfigNode node)

{

PluginConfiguration config = PluginConfiguration.CreateForType<SprinGSetup>();

config.SetValue ("Spring Value", SpringMass);

config.save();

}

public override void OnLoad(ConfigNode node)

{

PluginConfiguration config = PluginConfiguration.CreateForType<SprinGSetup>();

config.load();

SpringMass = config.GetValue<float>("Spring Value");

}

*/

// ---- Methodes ----

private void InitSLiderSpring()

{

print ("init started");

SpringInit = true;

TotalMass = vessel.GetTotalMass();

SpringMass = TotalMass / 3.0f; // repartition simple

// For this part i'm not sure at all :)

WheelColContainer = part.gameObject.GetComponentInChildren<WheelCollider>();

MyWheelCol = WheelColContainer.GetComponent<WheelCollider>();

SuspParameter = MyWheelCol.suspensionSpring;

// Ajust to new Mass

TweakSpring(0.0f);

}

private void TweakSpring(float Mass)

{

SuspParameter.spring = SpringMass + Mass;

}

}

}

Just to learn the way how code is created to take info in part !

For log at this moment no error , I'm looking how the debug info work

(tested Print, to see some variables in debug window)

steph

Edit :

For tonight I'm OUt sorry for that Stupi_chris , my neighbor make A ......... noise just

to bother me ;.;, it's impossible for me to stay concentrate.

I'm back tomorrow if i find some sleeping...........

sorry

Edited by stephm
Link to comment
Share on other sites

hello !

I have tested the pluggin with a 20t plane and a big (40t) , the range -20 to 20 is only on the 40 t plane.

but for the 20t plane the range is correct 0 to 40 !

I need to see how the range is affected by mass, I'm thinking I don't understand at all, the code writing above :D.

That make a perfect sense for me, because, same problem in Java for my first first code lol !!!!

Another thing the way to access data in ksp it's very similar to 3DS.

Edit 11/08/14 16h

// Just to see the effect in game by tweaking the wheelcollider's parameter

using UnityEngine;

using System;

using KSP.IO;

namespace SmallGearBayAR

{

public class SprinGSetup : PartModule

{

// -- Init Plugg on first start --

private bool SpringInit = false;

// ------ Mass Parameter ------

[KSPField(isPersistant = true, guiActive =true, guiActiveEditor = true, guiName ="Vessel's Mass Test", guiFormat = "F1")]

public float TotalMass; //vessel Mass

[KSPField(isPersistant = true, guiActive =true, guiActiveEditor = true, guiName ="Spring value", guiFormat = "F2")]

public float SpringResult = 0f; // show the value

public float SpringMass = 0f; //Spring Force

// ------ WheelCollider Spring Parameter ------

private WheelCollider MyWheelCol;

private WheelCollider WheelColContainer;

private JointSpring SuspParameter; // spring parameters

//private float SuspDist; // for further test

//----

[KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "Spring-Tweak"), UI_FloatRange(minValue = 0.0f, maxValue = 40.0f, stepIncrement = 0.5f)]

public float MassSlider = 0.0f;

public override void OnStart(StartState state)

{

base.OnStart(state);

if (!SpringInit) InitSLiderSpring();

}

public override void OnUpdate ()

{

base.OnUpdate();

float Test = SpringMass + MassSlider;

if ((HighLogic.LoadedSceneIsFlight) && (SuspParameter.spring != Test))

{

// adjust + tweak

TweakSpring(MassSlider);

}

}

// ---- save load methodes ----

/*

public override void OnSave(ConfigNode node)

{

PluginConfiguration config = PluginConfiguration.CreateForType<SprinGSetup>();

config.SetValue ("Spring Value", SpringMass);

config.save();

}

public override void OnLoad(ConfigNode node)

{

PluginConfiguration config = PluginConfiguration.CreateForType<SprinGSetup>();

config.load();

SpringMass = config.GetValue<float>("Spring Value");

}

*/

// ---- Methodes ----

private void InitSLiderSpring()

{

//Debug.Log("init started");

SpringInit = true;

TotalMass = vessel.GetTotalMass();

SpringMass = TotalMass / 2.0f; // repartition simple

// For this part i'm not sure at all :)

WheelColContainer = this.part.gameObject.GetComponentInChildren<WheelCollider>();

MyWheelCol = WheelColContainer.GetComponent<WheelCollider>();

SuspParameter = MyWheelCol.suspensionSpring;

// Ajust to new Mass

TweakSpring(0.0f);

}

private void TweakSpring(float Mass)

{

Debug.Log(String.Format("acces to value : SuspParameter.spring= {0:0.0}", SuspParameter.spring));

Debug.Log(String.Format("acces to value : MyWheelCol...spring= {0:0.0}", MyWheelCol.suspensionSpring.spring));

SpringResult = SpringMass + Mass;

SuspParameter.spring = SpringResult;

MyWheelCol.suspensionSpring = SuspParameter; // work but only if gear has a full cycle raise and lowwer

}

}

}

I use type of INFO to learn how to (for debug function in this case), is this kind of references are valid for all C# reference in KSP ?

Now I have a result , but it's not working real time, the gear need to raised and lowered, after that the new spring value is used.

I see in debug window the change of value, when slider moving, it's ok .

but I have still the same behavior about the range of the MassSlider, -20 to 20 for 40t and 0 to 40 for 20t plane..

I think it's under my nose but where :D !

Edit 21/08/14

Close Post : test abandonned

steph

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