Chrison Posted October 12, 2013 Share Posted October 12, 2013 Some ideas:- Search for editor mods and inspect their source. There are a bunch of Part Filters, for example.- Get into KSP's internals like us others. The object browser does have quite some hits for "Editor"- The KSP API doc does in fact contain an EditorLogic class that has an "public ShipConstruct ship;" that might be useful for you.Thanks, thats exactly what I needed to start off Specially the github page seems to be a well better documentation than the wiki pages are, specially if it comes to coding something (unfortunally...)I already did some research in the api using the object browser, but with that overhelming mass of stuff in there it is impossible to get a good starting point just by looking into it. Maybe a nice class diagram on the wiki would help people like me starting off (if I have some spare time, I'll create one and surely share it with the community)Talking 'bout editor mods, I was looking for subassembly source files, but unfortunally did not find any... this seemed to be a good start for me, as subassembly also handles loading parts which might become handy some day. Any hints where the sources are hidden? Am I just to blind to find them? Quote Link to comment Share on other sites More sharing options...
Diazo Posted October 12, 2013 Share Posted October 12, 2013 Subassembly is not implemented yet, that is coming in 0.22 which we don't have yet.There is a Subassembly Loaded mod for 0.21 you can take a look at, but not what you are talking about I think.D. Quote Link to comment Share on other sites More sharing options...
NathanKell Posted October 12, 2013 Share Posted October 12, 2013 Chrison, you might want to look at Mission Controller Extended. Does that, + missions.http://forum.kerbalspaceprogram.com/threads/43645-%28KSP-0-21%29-Mission-Controller-Extended-%28MC-Version-20-2%29-%28FORK%29-%28ALPHA%29Faark, yeah, my best bet right now is on setting engine configuration to trawl through fxgroup 'running', delete all emitters with "flame" and then add the appropriate ones....but I'm puzzled why SaveEffects and LoadEffects don't seem to work. Quote Link to comment Share on other sites More sharing options...
Swifty Posted October 19, 2013 Share Posted October 19, 2013 Hi,I'm trying to create a module that inherits from ModuleScienceExperiment and then overrides some of its behaviour.The aim is so I can then convert a resource "Experimental Results" into science points. I intend to do this by intercepting the experimentAction call doing some stuff (modifying the baseValue of x science experemnet based on number of experimental results) then calling the ModuleScienceExperiment function.I belive the function i need to 'override' is ModuleScienceExperiment.DelpoyAction(KspActionPara actPara). However, this function is not virtual or abstract.But this is not nescaraly a problem as I think i can use new public void DelpoyAction(KspActionPara actPara){ some new stuffbase.DelpoyAction(actPara);}However, either o DelpoyAction is not the action called by the gui systemo The gui call is going straight to the base class because new isnt really overrunning the base functiono or I need to override [KSPAction(?????)] [Question] Does anyone know how to override the [KSPAction(???)] when you don't know what ???? is?[Question] Is it even possible to complete override a parent class? My aim is basically to modify the base class without breaking needing to see its inner functioning. Now I thought it would have been possible by basivcly going though the class's signiture from the dll and just adding:public override Somefunction(paras){donewstuff();base.Somefunction(paras);}However, I think [KSPAction(???)] type defs int the original code may make this impossible. But i dont know enough about coding to say for sure...Any help, advice or points to programming tutorials related to this type of issue (hell even the actual name of what these ([KSPAction("Shutdown Generator")]) type of definitions are would be helpful cause then I'd be able to google it.ThanksSwifty Quote Link to comment Share on other sites More sharing options...
Faark Posted October 20, 2013 Share Posted October 20, 2013 Do you really have to use ModuleScienceExperiment? Maybe implementing IScienceDataContainer in your own PartModule will do it?Anyway, lets start with the "new" when declaring a member. Its sth completely different from "override". You might want to check out those links. The short version: "new" does pretty much nothing but tells your compiler to disable a warning since you actually want to do sth that looks wrong.Though admittedly its kind of confusing when using Unity, since they use a somewhat different technique for their MonoBehavior-Messages.So, beside from not using this PartModule, the best approach seems to work with KSPs even&action system. KSPAction is just an attribute. KSP looks them up at runtime and uses them to create the Events (right click ui) / Actions (=> action groups) properties for your part module. You might be able to simply disable them, eg. on Awake of your module... and re-disable them every time ModuleScienceExperiment might activate them, again. I don't see a way to entirely remove them, sadly. Quote Link to comment Share on other sites More sharing options...
Swifty Posted October 20, 2013 Share Posted October 20, 2013 (edited) Faark,Thank you for your reply. Your explanation of KSPAction & events is really appreciated. I went away after that post and got my book on CSharp and read about inheritance etc. Having done that I relised how simple what I was trying to do really is:public class SciLabZeroG : ModuleScienceExperiment{ [KSPEvent(active =true, guiActive =true, guiName = "Deploy")] new public void DeployExperiment() { print("Deploying Experiment"); base.DeployExperiment(); } [KSPEvent(active =true, guiActive =true, guiName = "Review Data")] new public void ReviewDataEvent() { print("Reviewing Data"); base.ReviewDataEvent(); } [KSPEvent(active =true, guiActive =true, guiName = "Reset")] new public void ResetExperiment() { print("Resetting"); base.ResetExperiment(); } [KSPEvent(active =true, externalToEVAOnly =true, guiActive =true, guiActiveUnfocused = true, guiName = "Reset")] new public void ResetExperimentExternal() { print("Resetting External"); base.ResetExperimentExternal(); }}With the above code you can now 'intercept' the players actions. Do some stuff and then call ModuleScienceExperimets without having to mess with the base module at all. Even better you can then modify the experiment whilst its in the memory. i.e. experiment.baseValue = 999999; etcSo now I have a very crude systems that uses a ModuleGenerator to convert scienceExperiments into Experimental results and then changes the basevalue of the given experiment based upon how many experimental results you have.Hopefully by the end of the day I'll have refined it enough to make a thread about my plans.------------------Edit below ---------------------------Arrrhhhh!!!!The above had been working all day but now I get:[Error] Action "Deploy Experiment" already defined.I just can't think why it would have worked earlier and then all of a sudden stopped.:-( Edited October 20, 2013 by Swifty Quote Link to comment Share on other sites More sharing options...
pizzaoverhead Posted October 20, 2013 Share Posted October 20, 2013 Swifty, you're attempting to overload a method usingnew public void DeployExperiment()You need to overload it like this:public overload void DeployExperiment()As a bonus, on typing "public overload", intellisense will show a list of all the things you can overload. Quote Link to comment Share on other sites More sharing options...
Swifty Posted October 20, 2013 Share Posted October 20, 2013 Thanks pizzaoverhead. I can't overload as the method is not virtual, abstract or already an override.Do you think the problem is caused by using new? I'd thought it was down to the KSPEvent/KSPAction attributes.I'd kind of thought using new was just like a different scope or namespace. Quote Link to comment Share on other sites More sharing options...
BananaDealer Posted October 21, 2013 Share Posted October 21, 2013 Welp, I'm having headaches...I'm trying to create data storage drives for SCIENCE! (you can read more from my signature, last page of the mod thread)...The drives will function similarly to a command pod's ability to store EVA reports from different environments, but with a focus on "external" equipment- Mystery Goo and such. The intention is to create a way to store data gathered from one set of equipment, leaving it free to be used in a different environment; instead of having data from "external" experiments stored directly on the equipment used.The capacity of the drives will also be dependant on the size of each experiment stored (the "Mits" value of each experiment). For instance, the Basic Data Drive, which has a capacity of 20 Mits, can hold either one 20-Mit experiment or 4 5-Mit ones.Attempting to store the same results (i.e- them being from the same equipment and environment) from experiments will result in only the most current one being stored (like with EVAs/Crew Reports). Results from the same experiment/equipment but from different environments will be stored alongside each other.These drives will of course have an energy requirement similar to stock probe parts.That said, I've been trying to figure how to code this most of the day... Lets just say I haven't done scripting, ever...Anyone feel like helping? Message me if you're interested! Quote Link to comment Share on other sites More sharing options...
BananaDealer Posted October 21, 2013 Share Posted October 21, 2013 (edited) Ok... So... As per my previous post, I've been trying to figure out how Mits are handled...As far as I've managed to gather, Mits are used for antennae transmissions where each packet the antenna sends is 2 Mits of the data being sent. Mits don't seem to be an actual resource that can be accumulated, however...Based on several experiments, I have determined that 1Mit is equal to 0.3 science when all other variables are ignored and the experiment is performed for the first time, on the Launchpad.I have no idea where I'm going with this however... Edited October 21, 2013 by BananaDealer Quote Link to comment Share on other sites More sharing options...
TaranisElsu Posted October 31, 2013 Share Posted October 31, 2013 I have been working on a set of examples that I hope people will find useful for learning how to write plug-ins for KSP and as a starting point for their mods: http://forum.kerbalspaceprogram.com/threads/56053 and https://github.com/taraniselsu/TacExamplesI hope that helps. Quote Link to comment Share on other sites More sharing options...
BananaDealer Posted October 31, 2013 Share Posted October 31, 2013 I have been working on a set of examples that I hope people will find useful for learning how to write plug-ins for KSP and as a starting point for their mods: http://forum.kerbalspaceprogram.com/threads/56053 and https://github.com/taraniselsu/TacExamplesI hope that helps.Sir, you might just have saved my bacon. Quote Link to comment Share on other sites More sharing options...
MentosDealeR Posted November 1, 2013 Share Posted November 1, 2013 i dont think anyone else (except devs and mods) know eitherthis thread will have 150% more people posting once the docs are up. before then no one will even really bother writing anything...so i guess we\'ll just have to wait for now patiently for the big bang of new parts appearing out of nowhere ;Phey anyone wanna team up with me?? i can write c++ (and c# doesnt look that different) but i have no clue about 3d designing and all thatwould like to make some parts though and if you dont know programming.... Hello, I am a 17 year old dutch student and i have wanted to make kps parts for some time now but i dont have any programming skills.i do know programs like sketchup inside out and i have used it quite a lot for various projects.I am willing to learn other 3D modelling softwares if sketchup doent let me create nice looking partsif you wanna work together, write me an emaildemy_msn-ac@hotmail.comcya Quote Link to comment Share on other sites More sharing options...
Raptor831 Posted November 1, 2013 Share Posted November 1, 2013 How would I check to see if the user is in IVA or not? Did some searching and checked the wiki but didn't find anything. I'm sure there's a simple check (i.e. isIVA) or something, but I'm missing it so far. Quote Link to comment Share on other sites More sharing options...
TaranisElsu Posted November 2, 2013 Share Posted November 2, 2013 How would I check to see if the user is in IVA or not? Did some searching and checked the wiki but didn't find anything. I'm sure there's a simple check (i.e. isIVA) or something, but I'm missing it so far.if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)https://github.com/taraniselsu/TacLifeSupport/blob/master/Source/LifeSupportController.cs#L475 Quote Link to comment Share on other sites More sharing options...
Raptor831 Posted November 2, 2013 Share Posted November 2, 2013 if (CameraManager.Instance.currentCameraMode == CameraManager.CameraMode.IVA)https://github.com/taraniselsu/TacLifeSupport/blob/master/Source/LifeSupportController.cs#L475Thank you. Just what I needed. Quote Link to comment Share on other sites More sharing options...
drcoxfate Posted November 2, 2013 Share Posted November 2, 2013 Hello, everyone!I am working on a project the result of which would be a joystick/controller system with feedback from KSP. The feedback surely needs some communication with KSP and that requires to create a plugin. I was wondering if anyone here could show me how to get the following done:I need to make a plugin that would allow to receive an access to the vessel's speed which it can pass to.. say a simple Label object in C#.Thanks in advance! Quote Link to comment Share on other sites More sharing options...
MD5Ray01 Posted November 2, 2013 Share Posted November 2, 2013 (edited) Sorry about this post, but I'm trying to set up a fix for a part that got updated for .22. It's an escape pod (the SpaceTech escape pod, Which was updated by Joe Beauchamp). I'm trying to get it so that way Kerbals can grab onto it in order to board. Are there any parameters I have to adjust at all? Edited November 2, 2013 by MD5Ray01 Quote Link to comment Share on other sites More sharing options...
Raptor831 Posted November 3, 2013 Share Posted November 3, 2013 Hello, everyone!I am working on a project the result of which would be a joystick/controller system with feedback from KSP. The feedback surely needs some communication with KSP and that requires to create a plugin. I was wondering if anyone here could show me how to get the following done:I need to make a plugin that would allow to receive an access to the vessel's speed which it can pass to.. say a simple Label object in C#.Thanks in advance!You could pull the surface velocity and store it like this: string velocity = FlightGlobals.ActiveVessel.GetSrfVelocity ().ToString ();Not tested that, but should work.Also, had another question for everyone: How do you set up an event listener for a part's events (i.e. toggle gear, toggle antenna)? Searched for this and I can't find anything for KSP, though the few Unity things I found didn't seem to help much. Quote Link to comment Share on other sites More sharing options...
Galantir Posted November 5, 2013 Share Posted November 5, 2013 Anyone here who can tell me how to determine if the frame of reference is orbit or surface? Quote Link to comment Share on other sites More sharing options...
Faark Posted November 5, 2013 Share Posted November 5, 2013 Anyone here who can tell me how to determine if the frame of reference is orbit or surface?Vessel.IsLandedOrSplashed should work (except a few frames right after spawning a vessel, though that could be handled via Vessel.Situation). ProtoVessel has sth similar. Quote Link to comment Share on other sites More sharing options...
hab136 Posted November 6, 2013 Share Posted November 6, 2013 How can I programmatically add a stock part to the ship in the editor? For example, if I have a ship consisting of just a probe core, and I want to attach a stock fuel tank to it. I don't want to load something onto the cursor (EditorLogic.PartSelected()), because I need to add several parts parts at once (fuel lines, specifically).I see PartLoader.Instantiate(), EditorLogic.SpawnPart(), and part.AddChild(), but I haven't had much luck so far with those, nor can I find any documentation or examples.I've also thought about copying the current ship in memory, modifying my copy, and then saving it as a new file with ShipConstruction.SaveShip() and then loading it back, but that seems silly.Can anyone point me in the right direction? Quote Link to comment Share on other sites More sharing options...
ljdp Posted November 6, 2013 Share Posted November 6, 2013 Anyone know how I can send an event to a specific part? I'm trying to shut down an engine with enginePart.SendEvent("Shutdown")[code] but that shuts down all engines on the vessel. Quote Link to comment Share on other sites More sharing options...
Faark Posted November 7, 2013 Share Posted November 7, 2013 ljdp: See forum.kerbalspaceprogram.com/threads/54348-Any-way-to-toggle-gear-solar-panels-from-codehab136: Have you checked out public ShipConstruct EditorLogic.ship ... that and its add method looks promising. Quote Link to comment Share on other sites More sharing options...
drcoxfate Posted November 7, 2013 Share Posted November 7, 2013 Thanks, Raptor831! I'll check that as soon as I can! 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.