Jump to content

Changed API in KSP 1.0


Recommended Posts

It looks like the old method for getting the true atmospheric cutoff height doesn't work anymore.


mainBody.atmosphereScaleHeight * 1000 * Math.Log(1e6)

atmosphereScaleHeight isn't there anymore.

I'm seeing: CelestialBody.atmosphereDepth

That might accomplish the same thing, anyone know?

It also looks like the onScienceReceived GameEvent returns a ProtoVessel object in addition to the science amount and ScienceSubject that were returned before. That could be useful for checking if the science returned is from a specific vessel for contracts.

Edited by DMagic
Link to comment
Share on other sites

It looks like the old method for getting the true atmospheric cutoff height doesn't work anymore.


mainBody.atmosphereScaleHeight * 1000 * Math.Log(1e6)

atmosphereScaleHeight isn't there anymore.

I'm seeing: CelestialBody.atmosphereDepth

That might accomplish the same thing, anyone know?

It also looks like the onScienceReceived GameEvent returns a ProtoVessel object in addition to the science amount and ScienceSubject that were returned before. That could be useful for checking if the science returned is from a specific vessel for contracts.

See this: http://forum.kerbalspaceprogram.com/threads/116893-atmosphereScaleHeight-of-CelestialBody?p=1870095#post1870095

Link to comment
Share on other sites

On the new streamlined keybind settings in KSP 1.0, there are some keybinds that have been removed.

Notably all the "Docking Mode" controls are gone. So GameSettings.DockingYawLeft and so on.

The only Docking keybind left is the Docking_toggleRotLin, all the other keybinds with "Docking" in their name are gone.

I did not notice any replacement keybinds get added, although there is a new "EVA_Board" keybind now.

D.

edit: It also looks like Loading a vessel no longer switches the scene. In 0.90 when you entered the editor and loaded a vessel, it would switch away and back to the editor scene. This was the "From Editor to Editor" line in the log.

In 1.0 this no longer happens, it just loads the vessel without switching the scene. This means that any code in the Start() method of the KSPAddon is no longer guaranteed to run fresh each time you load a vessel. I had some configuration code I had to move due to this.

edit2: Looks like there is now a GameEvents.onEditorLoad to detect when a vessel load happens now.

Edited by Diazo
Link to comment
Share on other sites

ApplicationLauncher code has been changed for the stock toolbar. I was having the issue of multiple toolbar icons being created whenever I switched to the flight scene before I made a fix for KSP 1.0. It looks like plugins need to only register their toolbar application one time with the ApplicationLauncher.Instance.AddModApplication() method, I think. With my mod, calling ApplicationLauncher.Instance.RemoveApplication() and then later calling ApplicationLauncher.Instance.AddModApplication() again will cause duplicates as I have mentioned.

Example

Link to My Code I'm Referring To

In the method RemoveFromAppLauncher() at line 63, within the if statement I was originally doing appLauncherButton = null, but I removed that to get the code to work for 1.0.

Edited by stevehead
code example
Link to comment
Share on other sites

ApplicationLauncher code has been changed for the stock toolbar. I was having the issue of multiple toolbar icons being created whenever I switched to the flight scene before I made a fix for KSP 1.0. It looks like plugins need to only register their toolbar application one time with the ApplicationLauncher.Instance.AddModApplication() method, I think. With my mod, calling ApplicationLauncher.Instance.RemoveApplication() and then later calling ApplicationLauncher.Instance.AddModApplication() again will cause duplicates as I have mentioned.

Example

Link to My Code I'm Referring To

In the method RemoveFromAppLauncher() at line 63, within the if statement I was originally doing appLauncherButton = null, but I removed that to get the code to work for 1.0.

I don't think it will help but there's something wrong ;)

Line 72 :

GameEvents.onGUIApplicationLauncherReady.Remove(OnGuiAppLauncherDestroyed);

Line 144 :

GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGuiAppLauncherDestroyed);

Link to comment
Share on other sites

I don't think it will help but there's something wrong ;)

Line 72 :

GameEvents.onGUIApplicationLauncherReady.Remove(OnGuiAppLauncherDestroyed);

Line 144 :

GameEvents.onGUIApplicationLauncherDestroyed.Add(OnGuiAppLauncherDestroyed);

Thanks. I'll look into it. The App Launcher code I have is a mishmash of examples I used when first writing the plugin. Now that I "somewhat" have an idea of how it actually works, I'm going to go back and get the code "right". Luckily, it just works for me as of this moment.

Link to comment
Share on other sites

Looks like ModuleEngineGimbal got an overhaul.

It now has Activate/Deactivate/Toggle actions, instead of just the Toggle action and some of it's KSPFields got renamed.

Your IDE should throw you any references to renamed fields if you are using them so not a huge deal, just make sure the Gimbal still behaves as expected in case they did not rename something but changed how it works behind the scenes.

D.

Link to comment
Share on other sites

ApplicationLauncher code has been changed for the stock toolbar. I was having the issue of multiple toolbar icons being created whenever I switched to the flight scene before I made a fix for KSP 1.0. It looks like plugins need to only register their toolbar application one time with the ApplicationLauncher.Instance.AddModApplication() method, I think. With my mod, calling ApplicationLauncher.Instance.RemoveApplication() and then later calling ApplicationLauncher.Instance.AddModApplication() again will cause duplicates as I have mentioned.

Example

Link to My Code I'm Referring To

In the method RemoveFromAppLauncher() at line 63, within the if statement I was originally doing appLauncherButton = null, but I removed that to get the code to work for 1.0.

Yeah I had problems with this too. Here's my solution: https://github.com/StupidChris/RealChute/blob/master/RealChute/RCToolbarManager.cs#L56-L67

Basically, the AppLauncher now booths in the MainMenu.So you need to do everything there. Add your button with the AddModApplication event, but make sure it ever runs once, and don't remove the button ever. Just filter it through scenes. That does the job.

Link to comment
Share on other sites

It also looks like the onScienceReceived GameEvent returns a ProtoVessel object in addition to the science amount and ScienceSubject that were returned before. That could be useful for checking if the science returned is from a specific vessel for contracts.

Yep, noticed this too. But actually, stuck debugging this now for the last few hours testing my mods for 1.0. I found the event just isn't firing at all... it is adding correctly but unless I am doing something wrong. Anyone else dealt with this change to GameEvent OnScienceReceived yet and had success?

The only change I made was to add the new protovessel parms as:- GameEvents.OnScienceReceived.add(newEventData<float,ScienceSubject,ProtoVessel>.OnEvent(OnScienceData));

and obviously I added ProtoVessel to the called method... but the method is not firing at all when I transmit or recovery science even though it is being registered to GameEvents.

EDIT: Several hours later, agonising debugging. It seems my contract is being spammed into the contract list.. so perhaps that has something to do with it and the event is being added to the wrong contract? Investigation continues.. So no one else has had this issue yet with 1.0? My contracts were all working fine with 0.90.

EDIT: Figured out the problem, new day, back to basics, but lost 8 hours of testing and hair pulling (what hair I have left). Lesson there: I usually test my mod updates in a vanilla copy, then a copy with most popular mods, but I skipped the first step rushing to get updates out. ScienceAlert was blocking the callback. xEvilReeperx has fixed it already. FYI for others I guess.

Edited by JPLRepo
Link to comment
Share on other sites

One I just noticed:

FlightGlobals.GetStaticPressure() now seems to return values in kilopascals rather than atmospheres. At least, I assume it's kilopascals, but it's roughly 100x greater than previous values, which matches.

Noticed this when practically every part in my mod spontaneously imploded due to excess pressure when I first put them on the pad ;)

Edited by FlowerChild
Link to comment
Share on other sites

EDIT: Figured out the problem, new day, back to basics, but lost 8 hours of testing and hair pulling (what hair I have left). Lesson there: I usually test my mod updates in a vanilla copy, then a copy with most popular mods, but I skipped the first step rushing to get updates out. ScienceAlert was blocking the callback

Sorry ;.; I'm coming up with a comprehensive "test these things" list for the rewrite so hopefully nasty bugs like that are much less likely to get through to releases

Link to comment
Share on other sites

One I just noticed:

FlightGlobals.GetStaticPressure() now seems to return values in kilopascals rather than atmospheres. At least, I assume it's kilopascals, but it's roughly 100x greater than previous values, which matches.

Noticed this when practically every part in my mod spontaneously imploded due to excess pressure when I first put them on the pad ;)

I think it's kPa also, but in this case SQUAD has tried to be helpful.

FlightGlobals.GetStaticPressure() * PhysicsGlobals.kPaToAtmosphere

is the new way to get the current pressure in Atm.

D.

Link to comment
Share on other sites

FlightGlobals.GetStaticPressure() * PhysicsGlobals.kPaToAtmosphere

is the new way to get the current pressure in Atm.

Word! Thanks for that. I immediately defined my own constant and hadn't thought to check for an existing one ;)

Link to comment
Share on other sites

Yeah I had problems with this too. Here's my solution: https://github.com/StupidChris/RealChute/blob/master/RealChute/RCToolbarManager.cs#L56-L67

Basically, the AppLauncher now booths in the MainMenu.So you need to do everything there. Add your button with the AddModApplication event, but make sure it ever runs once, and don't remove the button ever. Just filter it through scenes. That does the job.

Thanks stupid_chris! I got my code updated cleanly from your example.... it was a mess that just happened to work, lol.

Link to comment
Share on other sites

Has anyone figured out how to manipulate the Engineers report yet?

There is a new EngineersReport class and PreFlightTests namespace.

I've been playing around with them but can't figure it out.

Link to comment
Share on other sites

It should look like that :



public class MyEngReport : DesignConcernBase
{
// Is the Test OK ?
public override bool TestCondition()
{
return true;
}

// List of affected parts
public override List<Part> GetAffectedParts()
{
return this.list_0;
}

// Title of the problem description
public override string GetConcernTitle()
{
return "Stuff;
}

// problem description
public override string GetConcernDescription()
{
return "Stuff is wrong";
}

// how bad is the problem
public override DesignConcernSeverity GetSeverity()
{
return DesignConcernSeverity.WARNING;
}

// does it applies to Rocket, plane or both
public override EditorFacilities GetEditorFacilities()
{
return EditorFacilities.ALL;
}
}

Link to comment
Share on other sites

  • 2 weeks later...
It should look like that :



public class MyEngReport : DesignConcernBase
{
// Is the Test OK ?
public override bool TestCondition()
{
return true;
}

// List of affected parts
public override List<Part> GetAffectedParts()
{
return this.list_0;
}

// Title of the problem description
public override string GetConcernTitle()
{
return "Stuff;
}

// problem description
public override string GetConcernDescription()
{
return "Stuff is wrong";
}

// how bad is the problem
public override DesignConcernSeverity GetSeverity()
{
return DesignConcernSeverity.WARNING;
}

// does it applies to Rocket, plane or both
public override EditorFacilities GetEditorFacilities()
{
return EditorFacilities.ALL;
}
}

Yeah thanks Sarbian. I was looking at the classes already and it looks easy to add your own checks like you describe, but I was trying to figure out how to turn off some of the design concern checks on some parts etc. as it has some defaults for checking if resources are used, or not. Eg: RCS fuel in command pod but no RCS thrusters you get a warning about not having anything that uses the resource. Also, how it reports no parachute for some reason in some circumstances and not others.. When the pod does have a parachute. It's obviously bugged. But I haven't gotten far yet into looking into it as I am a bit time poor. So was wondering if anyone else has played around with it.

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