genericeventhandler Posted August 20, 2015 Share Posted August 20, 2015 Hi, I've got this idea to help me start understanding how to mod, can anyone give me any ideas how to open and close all solar panels and radiators?Thanks GEScenario 1: GIVEN: I am on the ground WHEN: I am stationary and my solar panels are not open THEN: I open all solar panels and radiatorsScenario 2: GIVEN: I am on the ground WHEN: My speed is > 0 and my solar panels are open THEN: I close all solar panels and radiatorsScenario 3: GIVEN: I am not on the ground WHEN: Atmosphere Pressure > 0 and my solar panels are open THEN: I close all solar panels and radiators Link to comment Share on other sites More sharing options...
Diazo Posted August 20, 2015 Share Posted August 20, 2015 (edited) In this case, I will point you to the classic KSP modding trick of looking at another person's code. One of the biggest benefits of the requirement that all mods post their source, just be aware of the license the mod is released under as you have to respect that when copying code.In this case, The solar panel action group mod extends and retracts all solar panels with the P key. Note my comment about the license earlier, this mod is licensed All Rights Reserved so you can't copy it's code. What you can do however is use it to figure out how to interface with the Solar Panels. As there is no API documentation, looking at other peoples work is one of the few ways we have of figuring out the API and what different commands actually do.While you want to make conditional triggers, the extending and retracting part should be pretty similar and that should get you going.D. Edited August 20, 2015 by Diazo Link to comment Share on other sites More sharing options...
sarbian Posted August 20, 2015 Share Posted August 20, 2015 And here is how we do it in MJ : https://github.com/MuMech/MechJeb2/blob/master/MechJeb2/MechJebModuleSolarPanelController.cs#L46-L88 Link to comment Share on other sites More sharing options...
genericeventhandler Posted August 20, 2015 Author Share Posted August 20, 2015 Diazo: Thanks.Sarbian, that is awesome I've quickly glanced at the code and it seems to be fairly simple.My idea is for rovers. I'm always ripping the cells off because I forgot to retract them after stopping to recharge! I love mechjeb, it doesn't like retrograde orbits but that's fine 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