Robotengineer Posted February 10, 2015 Share Posted February 10, 2015 Is there a way to easily convert CelestialBody info into a ConfigNode? Without having to write out Yourcfg.AddValue() statements for each param you want? Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 10, 2015 Share Posted February 10, 2015 Ugh, that does make things a little more complex. You can still do it without reflection or dependencies though (which to me is preferable).You could build a reference on reaching the Main Menu which has all applicable mod parts and their intake area. The issue with this would be parts which can change (I imagine tweakscale could be a bit of an issue here unless you can query the rescale factor)foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("PART")){ float area; ConfigNode intakeNode = node.GetNode("AtmosphericIntake"); if (intakeNode != null) { float.TryParse(intakeNode.GetValue("area"), out area); modIntakeDict.Add(node.GetValue("name"), area); // Dictionary<string,float> (part name, intake area) }} Quote Link to comment Share on other sites More sharing options...
enneract Posted February 11, 2015 Share Posted February 11, 2015 Is there any way to insert a ScenarioModule into the game save\load queue other than using the KSPScenario annotation?I need my ScenarioModule loaded faster than that. Quote Link to comment Share on other sites More sharing options...
ctordtor Posted February 12, 2015 Share Posted February 12, 2015 I am calling Die() on a Kerbal, and it shows the KIA message below, however if I click on EVA the Kerbal(s) all come back to life, tried searching didn't really find anything.Sample code: public class TestModule : PartModule { private bool foundCrew; public override void OnStart(StartState state) { print("Hello Kerbin!"); base.OnStart(state); } public override void OnUpdate() { if (foundCrew) return; var crew = vessel.GetVesselCrew(); foreach (var c in crew) { foundCrew = true; StartCoroutine(KillKerbal(c)); } base.OnUpdate(); } private IEnumerator KillKerbal(ProtoCrewMember c) { yield return new WaitForSeconds(5); c.Die(); } } Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 12, 2015 Share Posted February 12, 2015 After killing the kerbal try adding: vessel.GetCrew().Remove©; Quote Link to comment Share on other sites More sharing options...
ctordtor Posted February 12, 2015 Share Posted February 12, 2015 (edited) After killing the kerbal try adding: vessel.GetCrew().Remove©;Gave that a shot, doesn't seem to make an effect. The EVA/IVA buttons are still available on their portraits and all of them are able to be revived. Edited February 13, 2015 by ctordtor Quote Link to comment Share on other sites More sharing options...
ctordtor Posted February 13, 2015 Share Posted February 13, 2015 Gave that a shot, doesn't seem to make an effect. The EVA/IVA buttons are still available on their portraits and all of them are able to be revived.In the logs I'm seeing:[Log]: [00:00:00]: Jebediah Kerman was killed.[Log]: [00:00:00]: Bill Kerman was killed.[Log]: [00:00:00]: Bob Kerman was killed.For grins, I added:if(vessel.GetVesselCrew().Remove(c)) print("Removed");But Removed doesn't show up in the log. Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 13, 2015 Share Posted February 13, 2015 Try this method from TACLS (when in doubt, find a reference ) Quote Link to comment Share on other sites More sharing options...
ctordtor Posted February 13, 2015 Share Posted February 13, 2015 Try this method from TACLS (when in doubt, find a reference )Well that certainly did the trick! Thanks for the reference. Unfortunately, now the KIA portrait is gone. I was really hoping to keep that just to needle the player :-D Quote Link to comment Share on other sites More sharing options...
Koobze Posted February 14, 2015 Share Posted February 14, 2015 (edited) Edit: Nevermind! Found that "flightID" does this exactly.I am trying to link two objects, and save the reference between them in a persistent KSPField. Just saving the pointer doesn't work since the address will change each time etc, is there some consistent way to get a specific object after saving and loading? I think that the "routine mission manager" mod has you manually name a docking port, which is then uses as a reference to find it again after load, but I wanted something more automatic. Is there an internal part-instance-id that stays consistent across saves? Or am I best to generate a random GUID for my part and reference that way? Thanks! Edited February 14, 2015 by Koobze Quote Link to comment Share on other sites More sharing options...
*Aqua* Posted February 14, 2015 Share Posted February 14, 2015 I found several id numbers which are saved for every part:cid- get it with Part.craftID- different for each part of a vessel- I don't know if it stays the same all the time.uid- get it with Part.flightID- different for each part- doesn't change on load/save and docking/undockingmid- get it with Part.missionID- same for for all parts of a vessel- is set when the vessel is created the first time (upon launch)- doesn't change on load/save and docking/undockinglaunchID- get it with Part.launchID- same for all part on the vessel- I don't know if it stays the same all the time.A lot about the use of this numbers are unknown. Quote Link to comment Share on other sites More sharing options...
Koobze Posted February 14, 2015 Share Posted February 14, 2015 Thanks, for now I am using flightID but I will keep an eye on it to see if it changes.On an unrelated note... I've been trying to figure out how to change a Kerbal's velocity, but I can't seem to get it right. Been trying to make a Star Trek style teleporter to beam down to the surface of the planet, but every time my Kerbal retains his orbit velocity and smashes into the planet. I've tried using the kerbal's vessel.ChangeWorldVelocity, changing his rigidbody.velocity, changing his obt_velocity, but nothing seems to work. Anyone know how to get this done? I've killed Jeb so many times now. And what is World Velocity anyway? I don't see anywhere to actually query it. Quote Link to comment Share on other sites More sharing options...
*Aqua* Posted February 14, 2015 Share Posted February 14, 2015 Look at how HyperEdit does it. Quote Link to comment Share on other sites More sharing options...
Koobze Posted February 14, 2015 Share Posted February 14, 2015 Good idea, completely forgot about HyperEdit despite abusing it all the time. Quote Link to comment Share on other sites More sharing options...
Lucius Posted February 19, 2015 Share Posted February 19, 2015 Hey quick question: so far has it proven possible to make a part cost science to first unlock (as in, first unlock the tech tree node, then to unlock the individual part for use costs science)? If so, how was it done? Even an example workaround, like I believe at one point interstellar was capable of doing it. Quote Link to comment Share on other sites More sharing options...
*Aqua* Posted February 19, 2015 Share Posted February 19, 2015 The mouse events let you figure out which UI elements you hover when you press a mouse button. I guess that's how it was done. Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 21, 2015 Share Posted February 21, 2015 (edited) Initialising a floatCurve from a part config.Everything I've read indicates I can just tag it as a KSPField and it works the same as most any other config variable. However I'm having no luck with this approach.[KSPField]FloatCurve torqueCurve = new FloatCurve();// inside FixedUpdate()torqueCurve.Evaluate(0.5); // returns zeroThe config for the module has this for the floatcurvetorqueCurve{ key = 0 1 key = 1 1}but evaluate always returns zero.I checked the MM cache and the torquecurve is inside the partmodule where I would expect it to be.Full source here Edited February 21, 2015 by Crzyrndm Quote Link to comment Share on other sites More sharing options...
*Aqua* Posted February 21, 2015 Share Posted February 21, 2015 I'm not sure about that, but I think adding the KSPField attribute doesn't imply, that the float curve is saved and loaded by KSP by default.You'll have to modify it:[KSPField(isPersistant = true)]Also make sure you test that on a newly launched vessel. Existing parts may not have that attribute if you launched them before you added it in your code. Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 21, 2015 Share Posted February 21, 2015 (edited) Nada, KSPField works on it's default values if you just tag it like I have done (persistent = false, no GUI, etc.). You can see it higher up the source page I linked for saturationScale (which is 100% confirmed working as intended). Also, tagging things with persistent = true when you don't need to permanently track them is a bad idea (exactly because of cfg changes not taking effect on old parts)EDITWith persistent = true, I took a look in the save file just to make sure. torqueCurve had no keys Edited February 21, 2015 by Crzyrndm Quote Link to comment Share on other sites More sharing options...
*Aqua* Posted February 21, 2015 Share Posted February 21, 2015 I found a very old thread about KSPField: http://forum.kerbalspaceprogram.com/threads/10296-0-15-code-update-PartModule-KSPField-KSPEvent-ConfigNode-and-PartResource?p=168279&viewfull=1#post168279If I understand that post right, KSPField can't handle complex data structures without some help. But again, it's a very old post. It could be different now. Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 21, 2015 Share Posted February 21, 2015 (edited) FloatCurve implements IConfigNode, which is what KSPField requires to functionI'm beginning to doubt my config placement this is so persistent. Does this make sense to someone other than me? Edited February 21, 2015 by Crzyrndm Quote Link to comment Share on other sites More sharing options...
sarbian Posted February 21, 2015 Share Posted February 21, 2015 You need to not initialize it in the description. [KSPField]public FloatCurve torqueCurve ;public override void OnAwake(){ if (torqueCurve == null) { torqueCurve = new FloatCurve(); }} Quote Link to comment Share on other sites More sharing options...
Crzyrndm Posted February 21, 2015 Share Posted February 21, 2015 (edited) *smacks head*<== forgot it has to be publictyvm sarbian Edited February 21, 2015 by Crzyrndm Quote Link to comment Share on other sites More sharing options...
Candre Posted February 22, 2015 Share Posted February 22, 2015 Just dropping in after a few years out-of-game.I'd like to know whether there are library restrictions in place for mod development - I faintly remember some sort of DLL inspection/sanitation to prevent malicious code from a while back. I'm toying with the idea of integrating a broad .NET library and I'm afraid it might get the boot because it's likely full of unmanaged/unrestricted code and other goodies like that. Or I just made this all up...Google couldn't relieve me, sorry.Thanks in advance!,Candre. Quote Link to comment Share on other sites More sharing options...
sarbian Posted February 23, 2015 Share Posted February 23, 2015 Some of the restrictions were lifted a while back. I know that "System.Diagnostics.Process" is still on the list, but I don't know if there is any other.Are you sure you really need big libs ? You may have problem with anything not targeting .NET 3.5. 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.