Padishar Posted May 6, 2014 Share Posted May 6, 2014 Is there a way to get the status of an asteroid for a plugin? For example, if it has entered Kerbins sphere of influence?I believe it is just a "Vessel" so the mainBody property should indicate what SOI it is in... Quote Link to comment Share on other sites More sharing options...
Robotengineer Posted May 6, 2014 Share Posted May 6, 2014 Is there a thread with all the information for writing plugins? With all the modules and such that are used by developers? Quote Link to comment Share on other sites More sharing options...
Xty Posted May 7, 2014 Share Posted May 7, 2014 (edited) How do you read a PartModule's Field's value?I've got this to loop through all the fields on a partmoduleforeach (BaseField field in module.Fields){ if (field.guiActive) { Debug.Log((part.name + " - " + field.guiName)); }}but now I would like to actually read the values of each field.edit: nvm field.GetValue(module) does it, the needing to pass in the partmodule confused me. Edited May 7, 2014 by Xty Quote Link to comment Share on other sites More sharing options...
MrHappyFace Posted May 7, 2014 Share Posted May 7, 2014 Does anyone know how to make a KerbalEVA go into ragdoll mode? I would assume you use KerbalEVA.isRagdoll = true? Quote Link to comment Share on other sites More sharing options...
Xty Posted May 7, 2014 Share Posted May 7, 2014 Could anyone tell me how I could get the information listed in a parts 'more information' frame in the editor, when a ship is in flight? Quote Link to comment Share on other sites More sharing options...
DMagic Posted May 8, 2014 Share Posted May 8, 2014 Could anyone tell me how I could get the information listed in a parts 'more information' frame in the editor, when a ship is in flight?That would be the GetInfo() string from the PartModule.public class YourClass : PartModule { public override string GetInfo() { return base.GetInfo(); } }Then just set some other string equal to that and display it in flight somehow, a screen message, a field in the right-click menu, etc... Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 10, 2014 Share Posted May 10, 2014 Hi everyone, I'm having a hard time understanding how I can load a parameter from the cfg file of a module.I mean:MODULE{ name = MyModule aDouble = value}I would like to have a field called aDouble in my class and read it from the cfg file, but I can't find how to do that Quote Link to comment Share on other sites More sharing options...
stupid_chris Posted May 10, 2014 Share Posted May 10, 2014 Hi everyone, I'm having a hard time understanding how I can load a parameter from the cfg file of a module.I mean:MODULE{ name = MyModule aDouble = value}I would like to have a field called aDouble in my class and read it from the cfg file, but I can't find how to do that Add [KSPField] attributes to public fields in your PartModule code, they will automatically be fetched by KSP. However, it's porbably important to know KSPField does not support doubles, use floats. Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 10, 2014 Share Posted May 10, 2014 Add [KSPField] it's porbably important to know KSPField does not support doubles, use floats.THAT WAS IT!? THE TYPE!? :'(Thank you very much, I just found out why I wasted one night awake ^^ Quote Link to comment Share on other sites More sharing options...
Castun Posted May 10, 2014 Share Posted May 10, 2014 Sorry if this has been answered in this thread already, but if I wanted to tweak somebody's source code and recompile it, what do I need? I'm on Windows 7. (I actually want to look into adding Toolbar functionality to a slightly outdated mod.) Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 10, 2014 Share Posted May 10, 2014 Sorry if this has been answered in this thread already, but if I wanted to tweak somebody's source code and recompile it, what do I need? I'm on Windows 7. (I actually want to look into adding Toolbar functionality to a slightly outdated mod.)Just a C# IDE and a copy of KSP, possibly Unity (but not necessarily).You can use one of the free versions of Visual C# (Like Visual C# Express 2010), or SharpDevelop (that is also open source). Make sure to add the references to UnityEngine and Assembly-CSharp, both located in the KSP installation folder (KSP/KSP_Data/Managed).You can grab Unity on their site. Quote Link to comment Share on other sites More sharing options...
Dunbaratu Posted May 10, 2014 Share Posted May 10, 2014 My advice would be to ignore it and use a textured plane or GUIText if you want good results. This is what I ended up having to do, just because of a problem I didn't know about before I started - KSP configured its drawing layers so that they have distance cutoffs for rendering, and they're set such that if I try to label something with giant letters really far away, the letters refuse to render if they're more than about 1.2 million meters or so from the flight camera (I'm not sure how the heck they get things like the distant Mun to render then - maybe that's on a different layer).But anyway I had to do it with 2d text objects where I project the 3D coordinates into viewport coordinates to figure out where to put the text. You were right, that's what I eventually had to do. Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 11, 2014 Share Posted May 11, 2014 How can I change the GUIname of my module? The property is read-only, so I can't assign directly. Quote Link to comment Share on other sites More sharing options...
stupid_chris Posted May 11, 2014 Share Posted May 11, 2014 How can I change the GUIname of my module? The property is read-only, so I can't assign directly.Why exactly would you change it? (I'm not exactly sure what it does precisely too) Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 11, 2014 Share Posted May 11, 2014 Why exactly would you change it? (I'm not exactly sure what it does precisely too)It appears to be the name that is displayed in the editor in the list of the part's module.When your right click, you get a list of the things it supports, like "Gimbal", "Control surface"... and of course "ClassNameOfMyModuleDirectlyFromTheFile". GUIname seems to be the string that is displayed there instead of the class name... I guess. Quote Link to comment Share on other sites More sharing options...
stupid_chris Posted May 11, 2014 Share Posted May 11, 2014 It appears to be the name that is displayed in the editor in the list of the part's module.When your right click, you get a list of the things it supports, like "Gimbal", "Control surface"... and of course "ClassNameOfMyModuleDirectlyFromTheFile". GUIname seems to be the string that is displayed there instead of the class name... I guess.It probably goes through that, but that's not what it does. IIRC, it takes the class name of the PartModule, removes "Module" at the beginning if there is one, and then inserts a space after each camel case. Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 11, 2014 Share Posted May 11, 2014 It probably goes through that, but that's not what it does. IIRC, it takes the class name of the PartModule, removes "Module" at the beginning if there is one, and then inserts a space after each camel case.... which is great news for me, since my modules don't follow that naming convention nor are in camel case Well, this issue can wait anyway. Thank you chris Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 11, 2014 Share Posted May 11, 2014 Sorry to bother everyone again, but what is the correct place to execute some code just before the flight begins?As of now I am doing:public override void OnStart(PartModule.StartState state){ if (!(state == StartState.PreLaunch)) return; // stuff}But I am getting all sorts of strange glitches, like KSPFields that inexplicably have no value anymore. Quote Link to comment Share on other sites More sharing options...
Robotengineer Posted May 11, 2014 Share Posted May 11, 2014 How do I sort through vessel types? I am making a pug in that warns you when there is an imminent asteroid collision with Kerbin, but I need to know how to sort out the asteroids and the space objects from the other vessels. Is there a dictionary type thing in C# as there is in Python? Quote Link to comment Share on other sites More sharing options...
cm2227 Posted May 13, 2014 Share Posted May 13, 2014 Does anybody want to help me with writing a hardware interface for MechJeb? I'm not a programmer and some tasks take much more time from me than from somebody who knows exactly what he is doing. Feel free to contact me! Quote Link to comment Share on other sites More sharing options...
blizzy78 Posted May 13, 2014 Share Posted May 13, 2014 How do I sort through vessel types? I am making a pug in that warns you when there is an imminent asteroid collision with Kerbin, but I need to know how to sort out the asteroids and the space objects from the other vessels. Is there a dictionary type thing in C# as there is in Python?You should look into LINQ. For example:List<Vessel> allVessels = ...IEnumerable<Vessel> spaceObjectVessels = allVessels.Where(v => v.vesselType == VesselType.SpaceObject);IEnumerable<Vessel> nonSpaceObjectVessels = allVessels.Where(v => v.vesselType != VesselType.SpaceObject); Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 14, 2014 Share Posted May 14, 2014 Does anybody know how I could make a ship uncontrollable?I tried disabling the ModuleCommand of the command pod / cockpit / whatever, but it just keeps working. I'm not a big fan of removing and readding the ModuleCommand because I've seen that doing this can break references at times, but I will if need be. Quote Link to comment Share on other sites More sharing options...
The_Duck Posted May 14, 2014 Share Posted May 14, 2014 Does anybody know how I could make a ship uncontrollable?I tried disabling the ModuleCommand of the command pod / cockpit / whatever, but it just keeps working. I'm not a big fan of removing and readding the ModuleCommand because I've seen that doing this can break references at times, but I will if need be.Check out the InputLockManager class. Quote Link to comment Share on other sites More sharing options...
Ippo Posted May 14, 2014 Share Posted May 14, 2014 Check out the InputLockManager class.Thanks man, it definitely does what I'm looking for. Now I only need to figure out what disables what Quote Link to comment Share on other sites More sharing options...
Robotengineer Posted May 14, 2014 Share Posted May 14, 2014 So I have done some research on Linq and other things. I don't whether to use IEnumerable or a foreach method for the vessel sorting. her is the code I have so far.using System;using UnityEngine;using System.Collections.Generic;using linq;namespace Asteroid_Warning{ public class asteroidWarning { List<Vessel> allVessels = new List<Vessels>; foreach(VesselType.SpaceObject in Vessels); { } }I don't know if the VesselType syntax is correct, and I think that the code isn't right. Though if I knew everything, I wouldn't be posting here. 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.