Cephei

The official unoffical "help a fellow plugin developer" thread

Recommended Posts

That looks incredibly tasty. I haven\'t booted up Visual Studio in a while, have mainly been working with Java.

Share this post


Link to post
Share on other sites

Is there a way to see if a part has a stage before it? I need to make this part not run its Active functions until the stage before it is gone.

Share this post


Link to post
Share on other sites

Anyone know how to get the position and vector velocity of a vessel?


vessel.orbit.getPositionAt(Planetarium.GetUniversalTime()) * Planetarium.InverseScaleFactor;

That\'s what it seems to be but the values don\'t make sense pertaining to my current altitude.

Share this post


Link to post
Share on other sites

Is there a way to see if a part has a stage before it? I need to make this part not run its Active functions until the stage before it is gone.

if (this.inStageIndex == StageManager.StageCount) 
{
}

This should check to see if the part is in the active stage. It looks like there are some other fancy stuff you can check in the stage manager.

Share this post


Link to post
Share on other sites

if (this.inStageIndex == StageManager.StageCount)

{

}

This should check to see if the part is in the active stage. It looks like there are some other fancy stuff you can check in the stage manager.

Well, it\'s not so much active stage as 'is this part exposed' or 'is this part the last part in its stage'

Share this post


Link to post
Share on other sites

Hrmm...

Maybe this?

foreach (Part counter2 in this.children) {
if (counter2.isAttached) { }
}

Share this post


Link to post
Share on other sites

Hrmm...

Maybe this?

foreach (Part counter2 in this.children) {
if (counter2.isAttached) { }
}

I\'ll try it, thanks. :)

Share this post


Link to post
Share on other sites

I\'m starting work on a deploy-able balloon part. I\'ve got buoyancy working, but I want it to work like a parachute (deployable). Does anyone have an example of how to switch meshes like the parachute module?

[mod]Do not talk about decompiling the game. I will not give you a second chance.[/mod]

Anybody knows how to display pressure?

ooh, I can help someone!

this.staticPressureAtm & this.dynamicPressureAtm

I\'m not sure if this is correct, but it seems to work for density

FlightGlobals.getAtmDensity(this.staticPressureAtm)

Share this post


Link to post
Share on other sites

Do not talk about decompiling the game. I will not give you a second chance.

uH8QQ.gif

:-[

Share this post


Link to post
Share on other sites

I created an oxygen tank of sorts. I\'ve noticed that it gets used at the same pace, no matter what warp I use. How do I fix this?

Share this post


Link to post
Share on other sites

I created an oxygen tank of sorts. I\'ve noticed that it gets used at the same pace, no matter what warp I use. How do I fix this?

If it\'s possible, try to get the warp multiplier, and adjust the oxygen exhaustion rate accordingly.

I\'m thinking something like.

public void adjustExhaust(<T> theWarpFactor)

{

if (theWarpFactor is something)

then set oxygen to certain speed something like

this.oxygenRate = theWarpFactor*this.oxygenRate

else

do something else

}

Excuse my really shitty psuedo code.

Share this post


Link to post
Share on other sites

@up I thought about it, but I can\'t find a way to get the warp factor.

How can I kill the crew? Is there a KillCrew() function or something simillar?

Share this post


Link to post
Share on other sites

How can I kill the crew? Is there a KillCrew() function or something simillar?

What kind of plugin are you develloping ?...

  • Like 1

Share this post


Link to post
Share on other sites

I\'m going for a 'Oxygen tank' part just to see how complicated it is to implement something easy.

Now, in order to do it, I need to know how to kill the crew and adjust the oxygen consumption when warp is used.

Share this post


Link to post
Share on other sites

@up I thought about it, but I can\'t find a way to get the warp factor.

How can I kill the crew? Is there a KillCrew() function or something simillar?

Yes, I\'m quite sure I saw something like that. Try 'vessel.'.

Share this post


Link to post
Share on other sites

Does anyone have an example of launching a UI of some kind? UnityEngine.GUI, console window, etc...?

Share this post


Link to post
Share on other sites

Does anyone have an example of launching a UI of some kind? UnityEngine.GUI, console window, etc...?

Try looking at r4am0n\'s and CardBoardBoxProcessor\'s MechJeb Autopilot. They have a GUI which you can see in their source code, you learn a lot by reading the code.

Then we have Unity\'s own documentation:

http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=gui

And some basic tutorial:

http://unity3d.com/support/documentation/Components/GUI%20Scripting%20Guide.html

How you apply it to KSP you\'ll have to figure out yourself, or by help from other people\'s source codes.

Share this post


Link to post
Share on other sites

What\'s the difference between:

OnPartActivate, OnPartAwake, OnFlightStart, etc.?

Basically, a part I\'m using needs to initialize some variables each time it\'s loaded. I\'m putting it in OnFlightStart at the moment, but I\'m getting some very strange behaviour which I think might be due to one of those variables not being properly initialized.

Share this post


Link to post
Share on other sites

OnPartActivate - happens when you press Spacebar and the stage with your part is activated.

OnPartAwake - I believe this is available when unpausing the game.

OnFlightStart - this happens when you click 'Launch' in the VAB and the ship is placed on the launch pad.

I\'m doing the initialization in onPartStart();

Share this post


Link to post
Share on other sites

onPartStart()... that\'s called whenever the part is loaded? So, putting it on the launch pad, switching to the vessel from the tracking station, etc?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now