tinfoyle Posted June 14, 2012 Share Posted June 14, 2012 Thanks to The_Duck and kellven. Sadly I am working the next few days, but after that I have nice vacation that I will be pouring into this fun project. GUI and inputs are all worked in I have been saving the actual calculations (which you two have helped out greatly) for last. Eventually the goal is to have a controlled hover from vertical engines, then recreate land-speeders. 8) Quote Link to comment Share on other sites More sharing options...
jimbob926 Posted July 5, 2012 Share Posted July 5, 2012 Hi guys,I wish to start developing plugins but have not found any useful resources to help me. I have intermediate knowledge of coding (mainly C++) and was wonderering how you guys learnt? Please could you point me to some kind of explanation of how to get started or tell me how. Quote Link to comment Share on other sites More sharing options...
Kreuzung Posted July 5, 2012 Share Posted July 5, 2012 Trying around, reading these forums and stealing a lot from other plugins. Quote Link to comment Share on other sites More sharing options...
I got BCed Posted July 13, 2012 Share Posted July 13, 2012 How do I reference a partmodule attached to a known part? Quote Link to comment Share on other sites More sharing options...
kellven Posted July 14, 2012 Share Posted July 14, 2012 Part.Modules is a PartModuleListPartModuleList has these:public PartModule this[int classID] { get; } public PartModule this[string className] { get; }Which are indexers is fuzzy memory serves, so if you know the classname of the PartModule:Part.Modules['MyModuleClassName']should resolve to the module you\'re looking for.This is assuming the system is actually implemented that far.Edit: Forgot that those indexers return a PartModule object. If you want a reference to your actual PartModule subclass, you need to cast it. To do so safely: // //class MyModuleClass: PartModule { } //Part MyPart; // MyModuleClass module = MyPart.Modules['MyModuleClass'] as MyModuleClass; if (module == null) { //Error stuff here }End of pedantic remindersHappy Moddings Quote Link to comment Share on other sites More sharing options...
Ranged23 Posted July 27, 2012 Share Posted July 27, 2012 im starting with making mdos, does any1 know a few good beginning projects/ tutorials? i read the wiki\'s ones. Quote Link to comment Share on other sites More sharing options...
Kreuzung Posted July 27, 2012 Share Posted July 27, 2012 class ModuleKrTestSpam :PartModule{ public override void OnActive() { print('OnActive'); } public override void OnAwake() { print('OnAwake'); } public override void OnInactive() { print('OnInactive'); } public override void OnLoad(ConfigNode node) { print('OnLoad'); } public override void OnFixedUpdate() { print('OnFiyedUpdate'); } public override void OnUpdate() { print('OnUpdate'); } public override void OnSave(ConfigNode node) { print('OnSave'); } public override void OnStart(StartState state) { print('OnStart:' + state); }}Works, but I\'m too tired to look when what is exactly called. Quote Link to comment Share on other sites More sharing options...
I got BCed Posted July 29, 2012 Share Posted July 29, 2012 Part.Modules is a PartModuleListPartModuleList has these:public PartModule this[int classID] { get; } public PartModule this[string className] { get; }Which are indexers is fuzzy memory serves, so if you know the classname of the PartModule:Part.Modules['MyModuleClassName']err, thanks. Tad over my head, will try to work though that.should resolve to the module you\'re looking for.This is assuming the system is actually implemented that far.Edit: Forgot that those indexers return a PartModule object. If you want a reference to your actual PartModule subclass, you need to cast it. To do so safely: // //class MyModuleClass: PartModule { } //Part MyPart; // MyModuleClass module = MyPart.Modules['MyModuleClass'] as MyModuleClass; if (module == null) { //Error stuff here }End of pedantic remindersHappy Moddings Quote Link to comment Share on other sites More sharing options...
Naelo Posted August 2, 2012 Share Posted August 2, 2012 I\'ve got a simple question:How does one control the main throttle from a plugin? Quote Link to comment Share on other sites More sharing options...
rwhwilliam Posted August 7, 2012 Share Posted August 7, 2012 Is it possible to tell another ship to 'unpack', and stay unpacked? Quote Link to comment Share on other sites More sharing options...
lstutzman Posted August 16, 2012 Share Posted August 16, 2012 Hey everyone, if anyone knows... Is there any way to actually step through my plugin code? I can usually do this on other projects by setting us VS to run an external program while debugging, or attach the debugger to the process itself, but it seems that KSP.exe won't allow this.Cheers Quote Link to comment Share on other sites More sharing options...
Earthpulse Posted August 16, 2012 Share Posted August 16, 2012 Hey everyone, if anyone knows... Is there any way to actually step through my plugin code? I can usually do this on other projects by setting us VS to run an external program while debugging, or attach the debugger to the process itself, but it seems that KSP.exe won't allow this.CheersThink the only thing you can do is using the print message and refer to the ingame debug log (alt +F2). Quote Link to comment Share on other sites More sharing options...
lstutzman Posted August 16, 2012 Share Posted August 16, 2012 Yeah, that's what I've been doing. Bummer, feels like 1990 all over again. Quote Link to comment Share on other sites More sharing options...
TAz00 Posted August 21, 2012 Share Posted August 21, 2012 Hi there, new user here, I have a question. How do I make a GUI window appear without making a new part?I want to make a basic craft sharing system with dropbox. I want my window to be visible in the editor and while flying. And maybe the save/load menu.I got 4 years of generic C# experience, blazed through all the example code, but I havn't played with Unity or 3D in general. Quote Link to comment Share on other sites More sharing options...
Zool Posted August 22, 2012 Share Posted August 22, 2012 (edited) AFAIK you can only load code through a part. I'm not sure exactly when it gets called, but you could try loading your window in the Part class, onEditorUpdate() function.I've been trying to change the rootpart of a loaded vessel, with very little luck. I've tried rebuilding the parent child heirarchy in vessel.parts, and reordered it in case it expects the rootpart == parts[0]. It seems like problem is that vessel and the rootpart reference the same gameobject, which is readonly, so I can't set it to the new rootpart. Am I missing something? Any Ideas? Edited August 22, 2012 by Zool Quote Link to comment Share on other sites More sharing options...
Slaine Posted August 28, 2012 Share Posted August 28, 2012 Hoping somone can help =) How do I communicate between parts? I have two classes that extend the Part class and I want one of them to keep an eye on the other.I found this piece of code in the source code for Zoxygen but I'm not entirely sure what it does and if it is what I'm loking for? It seems to go through all parts in the vessel and return an object of that part? int VPartCnt = PART.vessel.parts.Count; for (int i = 0; i <= VPartCnt - 1; i++) { if (PART.vessel.parts.ElementAt(i).GetType().Name == "LiquidFuelEngine") { PART.vessel.parts.ElementAt(i) seems to return the object of the part. But how do I access its methods? Quote Link to comment Share on other sites More sharing options...
Zool Posted August 29, 2012 Share Posted August 29, 2012 You should be able to cast the part as the correct class. int VPartCnt = PART.vessel.parts.Count; for (int i = 0; i <= VPartCnt - 1; i++) { if (PART.vessel.parts.ElementAt(i).GetType().Name == "LiquidFuelEngine") {LiquidFuelEngine Engine1 = (LiquidFuelEngine)PART.vessel.parts[i]; }You might be better off using a KSP event though, see the stickied thread on .15 for an example. Quote Link to comment Share on other sites More sharing options...
Kreuzung Posted August 29, 2012 Share Posted August 29, 2012 What about taking 'oldstyle' engines and derived classes into account too?foreach(Part p in PART.vessel.parts) { if (p is LiquidFuelEngine) { //something } else if (p is LiquidEngine) { //same again for older engines for compatibility with older part packs and plugins deriving from the simple engine such as MuMech or ElEnergy Quote Link to comment Share on other sites More sharing options...
lkj802 Posted August 29, 2012 Share Posted August 29, 2012 hi guys, got a problem im sure it has a simple fix but i am totally clue less, the problem is that my command pods dont have any kerbonauts in them, in the pod description it says that the pods can seat 3 kerbals each, but none of them show any kerbals. the starter pods show the kerbals, but my extra downloaded ones dont, such as the kosmos pod, nova silisko's bace pod, the MEM pod and others, im not sure why this has happened and i dont know how to fix it, i see videos on YouTube and people have the exact same pods but with kerbonauts inside them. the only anomaly is that my DSM pack pods show their kerbals and thats were i really dont understand whats going on. please help me even if you have the smallest advice anything will help.lkj802 Quote Link to comment Share on other sites More sharing options...
Kreuzung Posted August 30, 2012 Share Posted August 30, 2012 That's got nothing to do with plugins. The parts that don't have kerbals are missing the INTERNAL definition which was not necessary before .16, and the ones that have crew got it. Quote Link to comment Share on other sites More sharing options...
Echo 8 ÉRÀ Posted August 31, 2012 Share Posted August 31, 2012 Is it possible to add buttons to a part's right-click menu at runtime? I'm trying to make a PartModule with part.cfg configurable right-click menu entries.I could probably get away with hardcoding it (a lot of methods with KSPEvent attribute) and showing/hiding them as necessary, but it'd be nice if I could avoid doing that. Quote Link to comment Share on other sites More sharing options...
LaydeeDem Posted September 1, 2012 Share Posted September 1, 2012 Would it be possible to make a SRB in your active stage fire at a certain altitude? Example: I have retrorockets on my lander and they automatically fire at 400m.I'm really new to plugin making but I want get into writing plugins. Quote Link to comment Share on other sites More sharing options...
JnyJny Posted September 1, 2012 Share Posted September 1, 2012 Would it be possible to make a SRB in your active stage fire at a certain altitude? Example: I have retrorockets on my lander and they automatically fire at 400m.I'm really new to plugin making but I want get into writing plugins.I think that's a cool idea! I have no idea how to make that happen... yet Having a part that can trigger actions at predetermined altitudes or some other condition would be totally fun. Quote Link to comment Share on other sites More sharing options...
LaydeeDem Posted September 1, 2012 Share Posted September 1, 2012 I think that's a cool idea! I have no idea how to make that happen... yet Having a part that can trigger actions at predetermined altitudes or some other condition would be totally fun.I know it's possible, I know parachutes do it. But how to make an engine do it? Quote Link to comment Share on other sites More sharing options...
JnyJny Posted September 1, 2012 Share Posted September 1, 2012 I know it's possible, I know parachutes do it. But how to make an engine do it?Yes of course. Welp, I suspect we could look at MechJeb for a pretty good clue. 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.