Jump to content

Info on how to convert your Plugin to KSP 1.1


Recommended Posts

8 minutes ago, RangeMachine said:

Of course :)

  Reveal hidden contents

KsqNZtu.png

It's looks like class changed totally.

  Reveal hidden contents

zoDqsh3.png

 

Weird. Can think of a few ways to get the scaled space transform individually per body but seems odd there would be no list. I'll ask around with Squad staff.

Link to comment
Share on other sites

3 minutes ago, Red Iron Crown said:

Removed some posts from here regarding decompiling and accessing private fields, please do not violate the EULA/TOS.

Uh ? Thomas answer did not use anything private and was useful :(

Edited by sarbian
Link to comment
Share on other sites

1 hour ago, Alewx said:

@TriggerAu Nope it is not in the first line of the ksp.log.


Kerbal Space Program - 1.1.0.1172 (WindowsPlayer) Steam

That is my first line of the log.

 

@stupid_chris Thanks that helped.

 

The output_log.txt (windows) or player.log (I think on Linux) contains more info than the ksp.log including the engine string, etc

Link to comment
Share on other sites

I don't know why, but AppLauncher.Ready is always false for me in Awake, so I just removed that check as all other mods updated for 1.1 already did and was finally able to see my beautiful icon, and I believe it should be mentioned somewhere here.

Link to comment
Share on other sites

Just now, Ziw said:

I don't know why, but AppLauncher.Ready is always false for me in Awake, so I just removed that check as all other mods updated for 1.1 already did and was finally able to see my beautiful icon, and I believe it should be mentioned somewhere here.

I'm fairly sure that AppLauncher.Ready would always be false in Awake, and that this should be used in a Coroutine or Update cycle :P

Link to comment
Share on other sites

1 hour ago, InsaneDruid said:

So what is the syntax for the new ModuleGimbal?

gimbalRange is still here and used as default if the new values are not here.

gimbalRangeXP / gimbalRangeXN are the Positive and Negative X range ( 1 / -1 default). gimbalRangeYP / gimbalRangeYN for the Y

enableYaw / enablePitch / enableRoll should be obvious.

 

Link to comment
Share on other sites

1 minute ago, stupid_chris said:

I'm fairly sure that AppLauncher.Ready would always be false in Awake, and that this should be used in a Coroutine or Update cycle :P

I get it now, I'm just curious why it was needed before. And adding button to AppLauncher works perfectly fine even if AppLauncher.Ready is false.

Link to comment
Share on other sites

13 minutes ago, Ziw said:

I get it now, I'm just curious why it was needed before. And adding button to AppLauncher works perfectly fine even if AppLauncher.Ready is false.

Probably because you're getting lucky. I suggest you do it the right way by either sticking it into a Coroutine which only proceeds on Applauncher.Ready, an update cycle that does the same, or that you use the provided GameEvent, as im using for RealChute https://github.com/StupidChris/RealChute/blob/master/RealChute/RCToolbarManager.cs#L110

Link to comment
Share on other sites

But GameEvents.onGUIApplicationLauncherReady was broken in 1.0.5, that is why everyone built a workaround, but I agree with you and will fix accordingly

Link to comment
Share on other sites

5 minutes ago, Ziw said:

But GameEvents.onGUIApplicationLauncherReady was broken in 1.0.5, that is why everyone built a workaround, but I agree with you and will fix accordingly

No it wasn't, I used it throughout 1.0.x :P What change is that it started going off between frame changes and went back on after, leading to multiple buttons if you didn't put a check to see if you had already added the button, and that you had to set it up from the MainMenu screen

Edited by stupid_chris
Link to comment
Share on other sites

8 hours ago, Agathorn said:

Did that work for you? Because that is what I tried to do but it wouldn't actually go away.

Yeah, you have to unbundle all of KSPedia and Squadcore, or delete them from project assets, then delete the squadcore.xml. if you have any assets files set to squadcore bundle the xml will return when you update.

as far as building, the actual bundle output is in a new folder AssetBundles in the unity project root with extension *.ksp. but far as I can tell the bundle is only built with the prefab you select, not any of the dependencies (shaders, textures, animations etc), at least those are not showing in assetbundle compiler tool.  the I havent' tried loading anything yet. How did you get to your assetbundle without any extension?

Link to comment
Share on other sites

7 minutes ago, stupid_chris said:

No it wasn't, I used it throughout 1.0.x :P What change is that it started going off between frame changes and went back on after, leading to multiple buttons if you didn't put a check to see if you had already added the button, and that you had to set it up from the MainMenu screen

It's not what I remember, I remember an exception being thrown inside KSP's code when you went from KSC straight into Launchpad by selecting the craft without going into VAB/SPH first. Anyway, it's all in the past now and now it works perfectly fine, I've already changed my code.

BTW Mr Roverdude in his USI LS mod never checks for AppLauncher.Ready and goes straight into ApplicationLauncher.Instance.AddModApplication in Awake(), that is I why I thought this check is redundant now.

Link to comment
Share on other sites

Just now, Ziw said:

It's not what I remember, I remember an exception being thrown inside KSP's code when you went from KSC straight into Launchpad by selecting the craft without going into VAB/SPH first. Anyway, it's all in the past now and now it works perfectly fine, I've already changed my code.

BTW Mr Roverdude in his USI LS mod never checks for AppLauncher.Ready and goes straight into ApplicationLauncher.Instance.AddModApplication in Awake(), that is I why I thought this check is redundant now.

Which is a bad practice to skip safety checks which are given to us. Perhaps it is currently redundant, but in the situation it changes, that solves you a bug hunt.

Link to comment
Share on other sites

From the Changelog thread:

Quote

Save/Load (and KSPField) support for VesselModules.

Does this mean I no longer have to create data storage partModules and can now use this?

For example:

 

public class TestVesselModule : VesselModule
{
[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false)]
public float test = 0;
public void OnStart()
{
Debug.Log(test);
}
public void OnDisable()
{
test = 10;
}
}

When I launch a new vessel and so this code runs the first time, this will print a value of zero to the log. Then when I return to the space center and return to the vessel, the value of "test" persists and a value of ten gets printed to the log correct?

No additional steps (so no ModuleManager script as VesselModule gets automatically added) are required right?

D.

Edited by Diazo
Link to comment
Share on other sites

Whats changed in Modules?

 

[KSPEvent(guiActive = true, guiName = "Start Data Linkup", active = true)]
        public void StartDataMCE()
        {}

Doesn't seem to show an action button anymore when right clicking on a part with your custom modules.

 

EDIT:  never mind just seems its a little wonky in the game.. Sometimes its there sometimes its not.  Hmmm.

Edited by malkuth
Link to comment
Share on other sites

1 hour ago, Diazo said:

From the Changelog thread:

Does this mean I no longer have to create data storage partModules and can now use this?

For example:

 


public class TestVesselModule : VesselModule
{
[KSPField(isPersistant = true, guiActive = false, guiActiveEditor = false)]
public float test = 0;
public void OnStart()
{
Debug.Log(test);
}
public void OnDisable()
{
test = 10;
}
}

When I launch a new vessel and so this code runs the first time, this will print a value of zero to the log. Then when I return to the space center and return to the vessel, the value of "test" persists and a value of ten gets printed to the log correct?

No additional steps (so no ModuleManager script as VesselModule gets automatically added) are required right?

D.

That's what it looks like! I'm really looking forward to using this myself. (Will make updating ShipSections to work in flight mode a little easier).

Link to comment
Share on other sites

5 hours ago, TriggerAu said:

The output_log.txt (windows) or player.log (I think on Linux) contains more info than the ksp.log including the engine string, etc

@TriggerAuAh you are right. the Output.log contains all that, I normally just look at the ksp.log as that provides normally all the info that is required.

Thank you also.

Link to comment
Share on other sites

37 minutes ago, malkuth said:

Whats changed in Modules?

 


[KSPEvent(guiActive = true, guiName = "Start Data Linkup", active = true)]
        public void StartDataMCE()
        {}

Doesn't seem to show an action button anymore when right clicking on a part with your custom modules.

 

EDIT:  never mind just seems its a little wonky in the game.. Sometimes its there sometimes its not.  Hmmm.

Make sure your module is being loaded correctly, no problems here.

Just now, Alewx said:

@TriggerAuAh you are right. the Output.log contains all that, I normally just look at the ksp.log as that provides normally all the info that is required.

Thank you also.

If you're coding you really want to only use output_log.txt. It holds all the info you may possibly ever need and the stack traces to every error in the game.

Link to comment
Share on other sites

This works in 1.0.5:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using System.Reflection;
using System.Runtime.InteropServices;


Object  obj = EditorLogic.fetch;
string name = "\u0001";
var f = obj.GetType().GetField(name, BindingFlags.Public | bindingFlags.NonPublic | BindingFlags.Instance);

But returns null in 1.1

Anybody have any ideas what's not working? 

 

 

Link to comment
Share on other sites

2 minutes ago, stupid_chris said:

If you're coding you really want to only use output_log.txt. It holds all the info you may possibly ever need and the stack traces to every error in the game.

So far Welding did not cause problems of the size that I had to look the Output.log up.

Link to comment
Share on other sites

The stack trace are in KSP.log now. The main difference between the 2 is that   Output.log  has the engine info at the start and is full of annoying useless lines.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...