Aelixander Posted October 21, 2015 Share Posted October 21, 2015 Hello there!I am making a mod that adds a new resource to the game. And while I have successfully implemented that - I have a desire to complicate matters further.I would like the resource to 'decay' after a while. Now, this can easily be faked by having the parts that generate it, also have an always-on generator set to a negative value (thus always consuming it)...However, that's too easy to eject or otherwise render moot.What I would really want is to have this resource decay on its own, without the need for parts to fake it.Any advice?Thank you much- A Link to comment Share on other sites More sharing options...
Fengist Posted October 22, 2015 Share Posted October 22, 2015 Actually, if I'm not mistaken, a generator with a negative value will create the resource. If you can code in C#, it would be pretty easy actually. I just did something like that for my submarine. If they have the neutral buoyancy toggled on, every 10 seconds it consumes an electrical charge. Link to comment Share on other sites More sharing options...
Fengist Posted October 22, 2015 Share Posted October 22, 2015 Ok, as per the PM's, give this a try:MPUtils PluginRather than make a bunch of plugins to manage, I included it in the one for my Sub Pack so there'll be a lot of stuff there you won't use.For instructions on how to add the partmodule, you can find it on my website: Kerbaltopia under MPUtils documentation. Link to comment Share on other sites More sharing options...
Stoney3K Posted October 22, 2015 Share Posted October 22, 2015 Fengist is right. Using Resource.Request() with a negative value will add to the resource, while a positive value will decrease it.However, a ModuleGenerator *already* uses a negative sign in code (since the rate is positive), so a ModuleGenerator entry with a negative rate could work as a decay method.If you want to do it in code, put a statement in PartModule.OnFixedUpdate() which decays the resource. You *will* need to write your own code if you don't want to keep a possibility of sabotaging it through hacking the part config or ModuleManager. Link to comment Share on other sites More sharing options...
Aelixander Posted October 23, 2015 Author Share Posted October 23, 2015 Fengist is right. Using Resource.Request() with a negative value will add to the resource, while a positive value will decrease it.However, a ModuleGenerator *already* uses a negative sign in code (since the rate is positive), so a ModuleGenerator entry with a negative rate could work as a decay method.If you want to do it in code, put a statement in PartModule.OnFixedUpdate() which decays the resource. You *will* need to write your own code if you don't want to keep a possibility of sabotaging it through hacking the part config or ModuleManager.Ill be happy if it cant be sabotaged though parts ejection, lol. Link to comment Share on other sites More sharing options...
Mecripp Posted October 23, 2015 Share Posted October 23, 2015 You can also use Near Future plugin here http://forum.kerbalspaceprogram.com/threads/52042-1-04-Near-Future-Technologies-%28fully-operational-in-1-04%29 and there is also JDiminishingRTG plugin here http://forum.kerbalspaceprogram.com/threads/115938 Link to comment Share on other sites More sharing options...
Stoney3K Posted October 23, 2015 Share Posted October 23, 2015 Ill be happy if it cant be sabotaged though parts ejection, lol.In that case, ModuleManager the PartModule into any of the command pods. Those can't be ejected without rendering the entire ship useless. Out of curiosity, what kind of resource are you looking into here? Life support? Coolant? Ship wear? Link to comment Share on other sites More sharing options...
Aelixander Posted October 23, 2015 Author Share Posted October 23, 2015 In that case, ModuleManager the PartModule into any of the command pods. Those can't be ejected without rendering the entire ship useless. Out of curiosity, what kind of resource are you looking into here? Life support? Coolant? Ship wear?I'm working on an anti-mass set of parts, and the idea is that without maintainance (the generator being 'on') the artificial particles decay. Link to comment Share on other sites More sharing options...
Stoney3K Posted October 23, 2015 Share Posted October 23, 2015 I'm working on an anti-mass set of parts, and the idea is that without maintainance (the generator being 'on') the artificial particles decay.That should be no problem to integrate into your PartModule as it is.If you jettison the generator which has the decay logic, the logic will keep running even though the part is not on the active vessel. Your "Antimatter" resource will drop to zero if you have no separate storage part for it. (PartModules will run on any vessel or debris within physics range, not just the active)Conversely, if you *have* a separate storage part (containment field generator of some sorts) you could put the decay logic in there. Dump the container and your resource is gone anyway, and if you somehow re-attach it or on ship startup, you can hook to the PartModule.OnAwake() method to re-set your resource count to zero.Simply put, a user can ditch their containment tank but it would do them no good because all of the antimatter will be gone once they re-attach it.As a good side-objective, gameplay wise, you could have the generator put out some heat and explode it when the containment field is full and the power is suddenly lost for too long. If a player doesn't attach enough radiators or kills the power, you have the chance of everything blowing up.Basically, add enough radiators and the particles will decay naturally without any ill side effects, but not enough radiators and your power drops... boom. Link to comment Share on other sites More sharing options...
Fengist Posted October 24, 2015 Share Posted October 24, 2015 I'm working on an anti-mass set of parts, and the idea is that without maintainance (the generator being 'on') the artificial particles decay.Did you get it working with my plugin? Link to comment Share on other sites More sharing options...
Aelixander Posted October 24, 2015 Author Share Posted October 24, 2015 Did you get it working with my plugin?Nope =( Link to comment Share on other sites More sharing options...
Fengist Posted October 24, 2015 Share Posted October 24, 2015 It's a plugin. You have to copy it to your gamedata diretory. Look in the .zip. Then, you have to add the partmodule to something on your ship. Read the docs I on the webpage. You don't load a .dll into visual studio. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now