hab136 Posted September 14, 2016 Share Posted September 14, 2016 (edited) 12 hours ago, katateochi said: I'm still very new writing KSP plugins, when you say take a look at the definition, where should I be looking? Both MonoDevelop and Visual Studio will show you the definition via autocomplete.. just start typing the name and it should pop up. There may be a better way in the IDE to browse them, I don't know. Most of the online documentation is out of date shortly after it's written/scraped. The IDE is the best source of truth. I just skim the online docs as a vague reference to find likely class names. EDIT: I just saw that with1.2, there are official API docs! Woohoo! Check out https://kerbalspaceprogram.com/api/index.html Edited September 14, 2016 by hab136 Quote Link to comment Share on other sites More sharing options...
katateochi Posted September 14, 2016 Share Posted September 14, 2016 @hab136 I'm using Monodevelop. Yeah just saw that the official API was now public. Joy! First thing I noticed was that there's an XKCDColors class, lol. Quote Link to comment Share on other sites More sharing options...
sarbian Posted September 14, 2016 Share Posted September 14, 2016 6 hours ago, katateochi said: @hab136 I'm using Monodevelop. Yeah just saw that the official API was now public. Joy! First thing I noticed was that there's an XKCDColors class, lol. For those who don't know the page : https://xkcd.com/color/rgb/ Quote Link to comment Share on other sites More sharing options...
kball Posted September 14, 2016 Share Posted September 14, 2016 New to KSP modding and C#/Unity platform in general. Is there any good way to conditionally reference KSPUtil to maintain backward compatibility? Quote Link to comment Share on other sites More sharing options...
blowfish Posted September 14, 2016 Share Posted September 14, 2016 2 minutes ago, kball said: New to KSP modding and C#/Unity platform in general. Is there any good way to conditionally reference KSPUtil to maintain backward compatibility? I don't think there's much reason to do that. The API has changed, and you should really only be trying to build against one version of KSP. Quote Link to comment Share on other sites More sharing options...
kball Posted September 14, 2016 Share Posted September 14, 2016 (edited) Ok, definitely down with that. Just wasn't sure if the references would break if building against 1.2 but running in 1.1.3. Should have tested that before posting, but testing now. Edit: Doesn't seem like that works. So we need to branch our plugins for the new version? Can that be right? Edited September 14, 2016 by kball Quote Link to comment Share on other sites More sharing options...
Malah Posted September 15, 2016 Share Posted September 15, 2016 18 hours ago, kball said: Ok, definitely down with that. Just wasn't sure if the references would break if building against 1.2 but running in 1.1.3. Should have tested that before posting, but testing now. Edit: Doesn't seem like that works. So we need to branch our plugins for the new version? Can that be right? Yes, I also use a branch when I want to keep support of an old version, but it's often useless (I've only keep support of KSP 1.0.5 because KSP 1.1.X wasn't stable on GNU/Linux), with KSP 1.2, I think I can drop support of KSP 1.0.5. On Monodevelop, when I read the Assembly-CSharp I see many private var which have strange character like a square with numbers. Can we access to these var with reflection? Exemple: for my mod QuickHide I work on the ApplicationLauncher, I've read the new API doc and I've found this: List<ApplicationLauncherButton> KSP.UI.Screens.ApplicationLauncher.appList = new List<ApplicationLauncherButton>() private List<ApplicationLauncherButton> KSP.UI.Screens.ApplicationLauncher.appListHidden = new List<ApplicationLauncherButton>() private List<ApplicationLauncherButton> KSP.UI.Screens.ApplicationLauncher.appListMod = new List<ApplicationLauncherButton>() private List<ApplicationLauncherButton> KSP.UI.Screens.ApplicationLauncher.appListModHidden = new List<ApplicationLauncherButton>() private and in Monodevelop I read this: private List<ApplicationLauncherButton> ; private List<ApplicationLauncherButton> ; private List<ApplicationLauncherButton> ; private List<ApplicationLauncherButton> ; Source: https://kerbalspaceprogram.com/api/class_k_s_p_1_1_u_i_1_1_screens_1_1_application_launcher.html Can I use appListMod in reflection? Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted September 15, 2016 Share Posted September 15, 2016 (edited) 9 minutes ago, Malah said: Yes, I also use a branch when I want to keep support of an old version, but it's often useless (I've only keep support of KSP 1.0.5 because KSP 1.1.X wasn't stable on GNU/Linux), with KSP 1.2, I think I can drop support of KSP 1.0.5. On Monodevelop, when I read the Assembly-CSharp I see many private var which have strange character like a square with numbers. Can we access to these var with reflection? Exemple: for my mod QuickHide I work on the ApplicationLauncher, I've read the new API doc and I've found this: List<ApplicationLauncherButton> KSP.UI.Screens.ApplicationLauncher.appList = new List<ApplicationLauncherButton>() private List<ApplicationLauncherButton> KSP.UI.Screens.ApplicationLauncher.appListHidden = new List<ApplicationLauncherButton>() private List<ApplicationLauncherButton> KSP.UI.Screens.ApplicationLauncher.appListMod = new List<ApplicationLauncherButton>() private List<ApplicationLauncherButton> KSP.UI.Screens.ApplicationLauncher.appListModHidden = new List<ApplicationLauncherButton>() private and in Monodevelop I read this: private List<ApplicationLauncherButton> ; private List<ApplicationLauncherButton> ; private List<ApplicationLauncherButton> ; private List<ApplicationLauncherButton> ; Source: https://kerbalspaceprogram.com/api/class_k_s_p_1_1_u_i_1_1_screens_1_1_application_launcher.html Can I use appListMod in reflection? Not according to the rules you can't. Refer to rule 7 of the Add-On rules: A better question would be why? the API for the Application Launcher contains public methods and vars to facilitate a mod integrating into that class. Edited September 15, 2016 by JPLRepo Quote Link to comment Share on other sites More sharing options...
Malah Posted September 15, 2016 Share Posted September 15, 2016 3 minutes ago, JPLRepo said: Not according to the rules you can't. Refer to rule 7 of the Add-On rules: A better question would be why? the API for the Application Launcher contains public methods and vars to facilitate a mod integrating into that class. I wanted to use this var to access and hide others mods applauncher At this time I use ApplicationLauncherButton[] _appLauncherButtons = (ApplicationLauncherButton[])Resources.FindObjectsOfTypeAll (typeof (ApplicationLauncherButton)); Quote Link to comment Share on other sites More sharing options...
sarbian Posted September 15, 2016 Share Posted September 15, 2016 No, the private fields name are obfuscated on build and could differ between Windows/OSX/Linux Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted September 16, 2016 Share Posted September 16, 2016 On 7/12/2016 at 9:09 AM, Papa_Joe said: The reason I do not use the class @Tralfagar mentioned is 1) It did not exist when these mods were created, and 2), it does not give me sufficient resolution for my needs. The class works just fine, but does not give you the ability to pick a specific seat, nor does it allow for crew swaps. In ShipManifest, I account for both. Therefore I've continued to use the method similar to CrewManifest, but with several enhancements. ShipManifest will allow seat to seat transfers within the same part, and part to part transfers (including swapping crew members if the seat/part is full in both cases). Additionally, in Realism mode, I've also included sounds and a delay to simulate the time needed to move from part to part or seat. Additionally, I've included support for ConnectedLivingSpace, When in realism mode and with CLS enalbled within SM, transfers now respect whether or not the parts have an internal connection to each other. if not, then the transfer must be accomplished by EVA. hmm... you gave me an idea. if you cannot transfer internally, I could change the xfer button to initiate an eva instead... Update. I've added the capability to send a Kerbal EVA in realism mode if CLS prevents an internal transfer. I will be releasing this feature soon in a point upgrade. thanks for giving me this great idea. @Tralfagar feel free to look over and leverage any of the code you see of value in SM. I hope it helps you in some small way. @Papa_Joe I'm having an issue where I am getting the kerbal EVA'd, but need to eject him, ie: not have him holding on to the ship. I'm using this: FlightEVA.fetch.spawnEVA(kerbal, p, p.airlock) but, when I do this: FlightGlobals.Vessels[i].rootPart.Rigidbody.AddForce(FlightGlobals.Vessels[i].rootPart.transform.up * ejectionForce); it doesn't seem to do anything, the kerbal stays attached. Any ideas? Quote Link to comment Share on other sites More sharing options...
Padishar Posted September 16, 2016 Share Posted September 16, 2016 (edited) 6 minutes ago, linuxgurugamer said: Any ideas? You can no longer use AddForce directly, you must do what it says in the thread about the changes in 1.2. Search for AddForce. Basically, you need to call Part.AddForce rather than calling the RigidBody directly. Also, I suspect there is a better way to make him let go of the hatch than smacking him with an invisible hammer... Edited September 16, 2016 by Padishar Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted September 16, 2016 Share Posted September 16, 2016 2 minutes ago, Padishar said: You can no longer use AddForce directly, you must do what it says in the thread about the changes in 1.2. Search for AddForce. Basically, you need to call Part.AddForce rather than calling the RigidBody directly. Thanks. I'm resurrecting EVA Parachutes, and fixing a couple of problems also Quote Link to comment Share on other sites More sharing options...
JoePatrick1 Posted September 16, 2016 Share Posted September 16, 2016 I am trying display a list of parts but when I try to use Part.partName it just says "Part" for all of them. Here is what I have using System; using System.Collections.Generic; using UnityEngine; using KSP; namespace AutoAbortSystem { public class ModuleAAS : PartModule { List<ModuleAAS> AASmodules = new List<ModuleAAS>(); List<Part> parts = new List<Part>(); public void Start() { } public void Update() { parts.Clear(); AASmodules.Clear(); foreach(Part part in FlightGlobals.ActiveVessel.parts) { parts.Add(part); if (part.gameObject.GetComponent<ModuleAAS>()) AASmodules.Add(part.GetComponent<ModuleAAS>()); } } public void OnGUI() { if(this == AASmodules.ToArray()[0]) GUILayout.Window(616173, new Rect(100,100,350,800), window, "Automatic Abort System", HighLogic.Skin.window); } public void window(int windowID) { foreach (Part part in parts) { if (part != this.part) GUILayout.Label(part.partName); else GUILayout.Label(part.partName + " (active)"); } } public void OnDestroy() { AASmodules.Remove(this); } } } Am I doing something wrong or is this a bug? Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted September 16, 2016 Share Posted September 16, 2016 5 minutes ago, JoePatrick1 said: I am trying display a list of parts but when I try to use Part.partName it just says "Part" for all of them. Here is what I have <snip> Am I doing something wrong or is this a bug? You want the part.partInfo.title or part.name Quote Link to comment Share on other sites More sharing options...
JoePatrick1 Posted September 16, 2016 Share Posted September 16, 2016 1 minute ago, JPLRepo said: You want the part.partInfo.title or part.name Thanks, that worked Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted September 16, 2016 Share Posted September 16, 2016 1 hour ago, linuxgurugamer said: Thanks. I'm resurrecting EVA Parachutes, and fixing a couple of problems also What @Padishar said. It's Underlined for a reason. Do not apply forces directly to rigidbodies. that is the job of the FlightIntegrator Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted September 16, 2016 Share Posted September 16, 2016 1 minute ago, JPLRepo said: What @Padishar said. It's Underlined for a reason. Do not apply forces directly to rigidbodies. that is the job of the FlightIntegrator Like I said, this is a mod I'm reviving, and this was some old code. Thanks for the info. Quote Link to comment Share on other sites More sharing options...
JPLRepo Posted September 16, 2016 Share Posted September 16, 2016 1 minute ago, linuxgurugamer said: Like I said, this is a mod I'm reviving, and this was some old code. Thanks for the info. NPs. I wasn't having a dig at you. Just for everyone's benefit. It's really important. Or bad things will happen. Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted September 16, 2016 Share Posted September 16, 2016 Just now, JPLRepo said: NPs. I wasn't having a dig at you. Just for everyone's benefit. It's really important. Or bad things will happen. No offense taken Any idea how to have a partmodule on an unfocused ship (but still close by) to continue to work? Quote Link to comment Share on other sites More sharing options...
blowfish Posted September 16, 2016 Share Posted September 16, 2016 20 minutes ago, linuxgurugamer said: Any idea how to have a partmodule on an unfocused ship (but still close by) to continue to work? Normal update methods should be run for any part on a vessel within physics range. Is there a case where that doesn't seem to be happening? Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted September 16, 2016 Share Posted September 16, 2016 Just now, blowfish said: Normal update methods should be run for any part on a vessel within physics range. Is there a case where that doesn't seem to be happening? That's what I thought. I'm EVA'ing a number of kerbals, and having a chute open up after they eva. It isn't working for some of them, so it's something in the code. This is the EVA Parachute mod I'm reviving Also, my understanding is that spawnEVA will spawn the kerbal and make the kerbal the active vessel. Will this also happen if you do a spawnEVA on a vessel which isn't the active vessel? Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted September 16, 2016 Share Posted September 16, 2016 Well, Update is running, so I need to figure out what else is going on. Quote Link to comment Share on other sites More sharing options...
Papa_Joe Posted September 16, 2016 Share Posted September 16, 2016 Wow, busy in my absence. Glad @JPLRepo was able to answer your questions! Quote Link to comment Share on other sites More sharing options...
linuxgurugamer Posted September 17, 2016 Share Posted September 17, 2016 So right now, after using spawnEVA to send a kerbal out on EVA, I use an ejection force to get him away from the ship. This has problems, mainly if the direction of the force happens to be into the ship, bad things happen (explosions, receding form Kerben at >40,000m/sec, etc). I'd rather just have the kerbal let go, but haven't yet found how to do this. Any ideas? Thanks in advance Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.