theSpeare Posted January 24, 2014 Share Posted January 24, 2014 Thanks Trigger I'll tinker a bit more. Learning modding is a lot easier with you guys around. Quote Link to comment Share on other sites More sharing options...
TriggerAu Posted January 24, 2014 Share Posted January 24, 2014 Thanks Trigger I'll tinker a bit more. Learning modding is a lot easier with you guys around.No probs, if you havent already then you should hang out in the #KSPModders IRC channel when youre coding, sometimes good to bounce ideas around in as well as here Quote Link to comment Share on other sites More sharing options...
Tidus Klein Posted January 24, 2014 Share Posted January 24, 2014 hi guys just started trying to make plugins for this game and figured i would try to make working precoolers for B9/ stock planes by dissecting the code from the KSP interstellar mode.and now i figured i would run some code by you guys... pleses coment[code:]using System;using System.Collections.Generic;using System.Linq;using System.Text;using UnityEngine;public class Module Precooler : PartModule{[KSPField(isPersistant = false, guiActive = true, guiActiveEditor = true, guiName = "Precooler status")] public string statusStr; protected ModuleResourceIntake attachedIntake; ///<summary> ///Called when the part is started by Unity. ///</summary> public override void OnStart (StartState state){ if (state == StartState.Editor) { return; } foreach (AttachNode attach_node in part.attachNodes) { if (attach_node.attachedPart != null) { List<ModuleResourceIntake> mres = attach_node.attachedPart.FindModulesImplementing<ModuleResourceIntake>().Where(mre => mre.resourceName == "IntakeAir").ToList(); if(mres.Count > 0) { attachedIntake = mres.First(); } } } part.force_activate(); } //add stuff to the log print ("I will make a precooler work in KSP if it kills me!") }}if (getResourceBarRatio (ResourceManager.FNRESOURCE_WASTEHEAT) >= 0.90 && Precooler.coolerState == Module Precooler. PrecoolerStates.ACTIVE) { Precooler.INACTIVE(); if (FlightGlobals.ActiveVessel == vessel) { ScreenMessages.PostScreenMessage ("Warning Heat critial, recomend emediate throttle down " , 5.0f, ScreenMessageStyle.UPPER_CENTER); } return;[/:code]its not done and i havent even tested it yet, 95% is just copyed from the mod and i have again yet to go through it any help is welcome Quote Link to comment Share on other sites More sharing options...
Rhidian Posted January 24, 2014 Share Posted January 24, 2014 hi guys just started trying to make plugins for this game and figured i would try to make working precoolers for B9/ stock planes by dissecting the code from the KSP interstellar mode.and now i figured i would run some code by you guys... pleses coment-snip-There aren't any colons within the code tags. That being said, what specifically do you want us to comment on? From what I can tell from the code above, I only see one function (OnStart() ), so I am wondering when the bottom half of the code will be called to print messages to the screen since OnStart is only called at the beginning of the scenes. Quote Link to comment Share on other sites More sharing options...
Tidus Klein Posted January 24, 2014 Share Posted January 24, 2014 Ha I don't know how to code!!!I just downloaded c++ yesterday and have been looking through the wiki plugin tutorial trying to figure it out so if you could post any helpful tutorials that are not videos(I don't have the time or bandwidth/ insert better excuse here)I would be grate full.Ps befor I go any further let me explain what I want the plugin to too1 a precooler must be attached to an intake to work. Check interstellar does that.2 for the plugin too use new specs on a part spisified in the parts .cfg3 for the plugin/ part to warn you when the engine is at 90% over heat4 precoolers use electisity to run. Can be set in .cfgI have tons of knowledge when it comes to .cfg editing just not coding a plugin (as you can see:()Again any tutorial/ tip is Wellcome Quote Link to comment Share on other sites More sharing options...
pizzaoverhead Posted January 24, 2014 Share Posted January 24, 2014 Is there a way to change the facing of the internal IVA camera without locking the mouse? I've been trying to change the camera transform's rotation, but it's having no effect.Figured it out. For anyone else looking to do this, here's the code:InternalCamera.Instance.transform.localEulerAngles = new Vector3(pitch, yaw, roll);FlightCamera.fetch.transform.rotation = InternalCamera.Instance.transform.rotation;Using eulerAngles instead of localEulerAngles makes the camera point down into the kerbal's neck.Without setting the FlightCamera's transform, instead of moving the internal camera, the IVA rotates around the camera, allowing you to point the capsule's window at the stage below. Quote Link to comment Share on other sites More sharing options...
MrHappyFace Posted January 29, 2014 Share Posted January 29, 2014 Is there a reason to use OnStart() or can I just use Start()? same for OnUpdate() and Update() Quote Link to comment Share on other sites More sharing options...
TriggerAu Posted January 29, 2014 Share Posted January 29, 2014 Is there a reason to use OnStart() or can I just use Start()? same for OnUpdate() and Update()If your using Monobehaviour's then the one to use is Start or Update . You can see a full list of the function names here - http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.htmlFor parts or other KSP events you can see the names in the ObjectBrowser Quote Link to comment Share on other sites More sharing options...
LethalDose Posted January 29, 2014 Share Posted January 29, 2014 Hey all,I'm having some troubles with the KSPField attribute. When I update the value of the variable, the change isn't reflected in the GUI. The attribute is applied with the declarations with the GUIActive set to true and a GUIName provided. I have this problem whether or not I set an initial value in the declarations, and across multiple data types (bool, str, & float).Any thoughts? I think I've seen this issue elsewhere, but I haven't seen a solution (or at least not a solution that I understand).Thanks! Quote Link to comment Share on other sites More sharing options...
MrHappyFace Posted January 29, 2014 Share Posted January 29, 2014 If your using Monobehaviour's then the one to use is Start or Update . You can see a full list of the function names here - http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.htmlFor parts or other KSP events you can see the names in the ObjectBrowserI have an EVAPartModule class that extends PartModule and overrides OnStart() and OnUpdate(). I then need to make a module extending EVAPartModule, but I, for some reason, cant override OnStart() or OnUpdate() in a class extending EVAPartModule. i am using 'public override void' for everything, should I use something else in place of public, like private or internal? Quote Link to comment Share on other sites More sharing options...
TriggerAu Posted January 29, 2014 Share Posted January 29, 2014 I have an EVAPartModule class that extends PartModule and overrides OnStart() and OnUpdate(). I then need to make a module extending EVAPartModule, but I, for some reason, cant override OnStart() or OnUpdate() in a class extending EVAPartModule. i am using 'public override void' for everything, should I use something else in place of public, like private or internal?Understood, so the Method should be the OnStart/OnUpdate ones, but sounds like the issue might be in the definition of the methods. If you can post the definitions of the classes/methods or pastebin the applicable code file I'm happy to have a look, just dont paste a massive swath of code in the thread .If you are worried about sharing the code publicly, but do want me to look then you can also PM me a link to something Quote Link to comment Share on other sites More sharing options...
timmers_uk Posted January 29, 2014 Share Posted January 29, 2014 Hey,(not sure if this deserves its own thread for the question or not)I'm putting together a fitness mod to model effects of long term travel on Kerbals, and when I was doing my initial coding I noticed that UT is passing in the TrackingStation and KSC scenes (but also that there seems to be a distinct lack of Vessels in FlightGlobals in the KSC scene).I'd like to avoid having any horrible time-holes if possible, but I'm not sure if time spent in these scenes counts towards the game? Could any of you gurus point me in the right direction on whether to have things running when not in flight?Thanks,Timmers Quote Link to comment Share on other sites More sharing options...
MrHappyFace Posted January 29, 2014 Share Posted January 29, 2014 Understood, so the Method should be the OnStart/OnUpdate ones, but sounds like the issue might be in the definition of the methods. If you can post the definitions of the classes/methods or pastebin the applicable code file I'm happy to have a look, just dont paste a massive swath of code in the thread .If you are worried about sharing the code publicly, but do want me to look then you can also PM me a link to somethingI am using these method definitions:public override void OnStart(StartState start)public override void OnUpdate() Quote Link to comment Share on other sites More sharing options...
TriggerAu Posted January 30, 2014 Share Posted January 30, 2014 I am using these method definitions:public override void OnStart(StartState start)public override void OnUpdate()Your definitions look right and I have done overrides of overrides in other classes before, but without more code I'm not sure what advice to give Quote Link to comment Share on other sites More sharing options...
TriggerAu Posted January 30, 2014 Share Posted January 30, 2014 Hey,(not sure if this deserves its own thread for the question or not)I'm putting together a fitness mod to model effects of long term travel on Kerbals, and when I was doing my initial coding I noticed that UT is passing in the TrackingStation and KSC scenes (but also that there seems to be a distinct lack of Vessels in FlightGlobals in the KSC scene).I'd like to avoid having any horrible time-holes if possible, but I'm not sure if time spent in these scenes counts towards the game? Could any of you gurus point me in the right direction on whether to have things running when not in flight?Thanks,TimmersTime in those scenes does count towards overall game time, the vessels are on rails during that period and when you go back to flight they will have moved. You can still track UT in those scenes using Planetarium.GetUniversalTime(), and then it depends what you are trying to capture as to whether/how you track vessels Quote Link to comment Share on other sites More sharing options...
timmers_uk Posted January 30, 2014 Share Posted January 30, 2014 Time in those scenes does count towards overall game time, the vessels are on rails during that period and when you go back to flight they will have moved. You can still track UT in those scenes using Planetarium.GetUniversalTime(), and then it depends what you are trying to capture as to whether/how you track vesselsThanks for that - confirms what I've been seeing - I've decided for now not to do any update processing in those scenes, but to keep it in mind as when I hit a 'live' scene (i.e. Flight), my first update gets a big bump in UT from the previous update time (which I'm persisting in a scenario config node).It also explains the unfortunate loss of Jeb + crew back when I left my machine on and sat at KSC whilst I went out for lunch Timmers Quote Link to comment Share on other sites More sharing options...
Faark Posted January 30, 2014 Share Posted January 30, 2014 (edited) I am using these method definitions:public override void OnStart(StartState start)public override void OnUpdate()What exactly does the compiler say?Also you might don't have to use KSP-events. They have nothing to do with the ones listed for MonoBehavior. This game engine does not use .NET's default inheritance system, so there is no interface for a MonoBehavior & its Unity "event" methods, neither have they to be virtual. Just implement the Method (Start/Update) and Unity will do "Stuff" (probably reflection) to find out what to call. If it was already implemented in a base class you can/have to use modifiers like "new" or "override", ofc. Edited January 30, 2014 by Faark Quote Link to comment Share on other sites More sharing options...
Rhidian Posted January 30, 2014 Share Posted January 30, 2014 Is it possible to change the position of a celestial body? If so, what function would be necessary and what effect might it have on the On-Rails simulation for orbits (ie if I moved Kerbol). Quote Link to comment Share on other sites More sharing options...
Tidus Klein Posted January 30, 2014 Share Posted January 30, 2014 HI guys its me again!I was wondering how i could tell a part (precooler) the heat of an engine behind it with out having to go and make a new resource for waste heat,in other words how does KSP track engine heating? and how could I access it.ps, also does anyone know how I could tell my code to change a part parameter during the parts activation. EX: precooler statues = active, reduce, standard parameters, Heat production by 10%all help is welcome Quote Link to comment Share on other sites More sharing options...
NathanKell Posted January 30, 2014 Share Posted January 30, 2014 Rhidian: yes, it's possible. If you moved Kerbol, presumably all the bodies orbiting it would move with it.Tidus Klein: a part's temperature is part.temperature. So you'd just check the temperature of the part attached to the bottom node of the precooler.Not sure what you're asking with the second question. Presumably you'd just add code in OnFixedUpdate to check if activated, and if so, do stuff? Quote Link to comment Share on other sites More sharing options...
Tidus Klein Posted January 30, 2014 Share Posted January 30, 2014 Thanks Nathan!just to see if you cant help with that last question let me state what all im trying for the code to do in a Code/ English way (don't worry that scentance is only somewhat confusing) ///precooler/ looks for intake air, if (blaablaa blaa code stuff, focused craft has resource.intake_air)==!null else (== null) ///looks for attached jet engine, if (attached_node, rearward.has module.engine/ uses velosity curve)==!null else (==null)///waits/ looks for activation if (precooler state = active)get.standard_part_parameters, Heat_production -10%) else (precooler state = inactive,) (return); I know that thats a little confusing especially sense I used a made up coding/ English language, but i hope this helps,again thanks for the heat adress Quote Link to comment Share on other sites More sharing options...
NathanKell Posted January 30, 2014 Share Posted January 30, 2014 Are you trying to change KSPI's precooler, or make your own? Quote Link to comment Share on other sites More sharing options...
Tidus Klein Posted January 30, 2014 Share Posted January 30, 2014 little bit of both,I would like to have one that works with ship velocity, ( I can cheat with this and just increase engine heat production and velocity curve,)but also dose't add a wast heat resource to the game, my original idea was to make a part with a high heat dissipation, and conductivity. but then that would have worked on rocket engines, (reason for the detection of intake air and velocity curve)so ya its basically a KSP I precooler with out the need for the waste heat resource. Quote Link to comment Share on other sites More sharing options...
theSpeare Posted January 31, 2014 Share Posted January 31, 2014 Anyone know how I can go about accessing the biome name where a vessel is located? Quote Link to comment Share on other sites More sharing options...
Faark Posted January 31, 2014 Share Posted January 31, 2014 @speareSame question was asked and answered in this same thread 10 days ago 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.