Jump to content

[1.2] BatteryActivator


Biff Space

Recommended Posts

BatteryActivator - v 1.1 for KSP 1.2
BatteryActivator allows batteries on an unmanned vessel to be activated if they have been switched off to conserve power.

Download v1.1 at SpaceDock

Overview
Since KSP 1.1, you can't use the on/off switch on a battery unless there is power available. If there is only one battery, or all batteries with charge are off, then an unmanned craft is dead - the batteries can't be activated because there is no power available... because the batteries are off!

This mod automatically pops up a one-button menu if the following conditions are met:
* vessel is unmanned
* there are charged batteries aboard
* no power is available because the batteries are switched off.

The button, when clicked, switches all batteries on, so the vessel is controllable again. This also causes the conditions for the menu to appear to become false, so it disappears.

There are no settings or configuration file.

Installation
The BatteryActivator folder needs to be unzipped and put in your KSP\GameData folder. 

Code
The source code is in the Source folder in GameData\BatteryActivator.

Version History

RELEASE (2016-10-30), v 1.1.0.0

- compiled with KSP 1.2

- Bug fixed - the presence of tourists used to prevent the appearance of the 'activate' GUI, now works normally for tourist-only ships.


RELEASE (2016-05-01), v 1.0.0.1

Licence
BatteryActivator, its associated files and the source code are all released under the GPL 3 licence, text here: http://www.gnu.org/licenses/gpl.txt.

Edited by Biff Space
update
Link to comment
Share on other sites

It depends what you mean by 'works'.   :)

In the sense "does BatteryActivator take notice of RemoteTech's connections, and only offer the 'Batteries On' button if there is a working transmission route?" then the answer is no. (ie taking 'works' to mean 'plays nicely with'.)

In the opposite sense, "does BA still work, even if RT stops control of the craft?" then the answer is yes. (ie taking 'works' = 'functions despite').

I don't play with RT myself. If there is a demand for integration I could have a look to see if it is feasible.

 

Link to comment
Share on other sites

If you wanted it to honor remote tech then there is no need to install it.  A craft without power can't run it's antennas and thus you would never be able to command the battery on.  Which is what stock does already.

Link to comment
Share on other sites

1 hour ago, bobprime said:

If you wanted it to honor remote tech then there is no need to install it.  A craft without power can't run it's antennas and thus you would never be able to command the battery on.  Which is what stock does already.

This makes sense. 

Link to comment
Share on other sites

Does this mod update all the time (every fixedupdate or something), or just when a flight scene is loaded? Or in other words how heavy is it on computations, and does it react if my crafts runs out of power in the middle of a reentry or something?

Link to comment
Share on other sites

I'm new to posting in the forums so I hope this isn't breaking any rules. I have a question about the install of this mod. The source folder that is mentioned to be included inside the Gamedata folder... does it have to be included inside the Gamedata folder in the installed game as well. Other mods I have used have had a Source folder outside of the Gamedata folder so I have added a Source folder myself under the main directory and that is where I put any Source contents from mods. Am I misunderstanding in doing this, or does this mod install differently and I keep the Source folder inside Gamedata?

Edited by Gryffyn
misspelling
Link to comment
Share on other sites

It updates all the time. This allows you to switch off the batteries in order to warp to a manoeuver node, and then switch on the batteries to turn the ship to the right orientation. It would be cumbersome to have to go back to the tracking centre and back to the ship to do this.

However, I don't think that the mod is particularly computationally intensive. Each update, it looks for crew, and quits immediately on finding them. It then has to look through the ships parts for electric charge (available and locked) and then if there is no charge available and charge locked away, it activates a minimal GUI. There is no complex (physics or graphics) stuff, it just walks the parts tree once counting resources.

Link to comment
Share on other sites

@Biff Space Hmmm, I love the idea of resurrecting the sleep mode ability for probes. But it would be awesome to have it behave the old way, without an extra UI. Is it possible to just enable the ability to click on that "x" marker?

Edited by Enceos
Link to comment
Share on other sites

11 minutes ago, Enceos said:

@Biff Space Hmmm, I love the idea of resurrecting the sleep mode ability for probes. But it would be awesome to have it behave the old way, without an extra UI. Is it possible to just enable the ability to click on that "x" marker?

Maybe you could create a change request in the bug tracker, and ask for an option in the settings menu, or maybe as part of the difficulty screen for this behavior?

Link to comment
Share on other sites

22 minutes ago, Warezcrawler said:

Maybe you could create a change request in the bug tracker, and ask for an option in the settings menu, or maybe as part of the difficulty screen for this behavior?

I will.

Link to comment
Share on other sites

11 hours ago, Enceos said:

@Biff Space Hmmm, I love the idea of resurrecting the sleep mode ability for probes. But it would be awesome to have it behave the old way, without an extra UI. Is it possible to just enable the ability to click on that "x" marker?

That would be a much better way to do this, but I am not familiar enough with Unity to know how to re-code an event (button click) that is already handled in KSP. It is presumably possible, but the mods I have released recently are all intended to be very simple, tiny, and low-maintenance. In the next day or two I hope to release updates for my two medium-sized mods, and then I want to work on another larger mod. Since the functionality intended is available in this mod, I'm not going to put effort into altering the GUI details. I hope Squad make this behavior configurable.

Link to comment
Share on other sites

On ‎2016‎-‎05‎-‎01 at 9:49 AM, Gryffyn said:

I'm new to posting in the forums so I hope this isn't breaking any rules. I have a question about the install of this mod. The source folder that is mentioned to be included inside the Gamedata folder... does it have to be included inside the Gamedata folder in the installed game as well. Other mods I have used have had a Source folder outside of the Gamedata folder so I have added a Source folder myself under the main directory and that is where I put any Source contents from mods. Am I misunderstanding in doing this, or does this mod install differently and I keep the Source folder inside Gamedata?

No.  The "source" is the human-readable programmed code of the mod.  The "mod" files are the compiled code, after they've been converted into information that is not human-readable but IS machine-readable.

Squad (the company that makes Kerbal Space program) allows anyone to create mods for the game, on the strictly-enforced condition that anyone who makes a mod also release the source code with it, or a description as to where it can be publicly found on the internet (such as a github or dropbox link.)  Releasing a mod without also releasing the source code is a HUGE no-no with this game, and people take it extremely-very seriously.

For the average end user like you or me, there's no use for it, because you need to be a programmer to understand it.  I suggest leaving it in the zipfile that you downloaded and just extracting the mod files into your GameData.  Again, whatever you do, DO NOT place the source code in your GameData folder -- anything in the GameData folder will be scanned by Kerbal Space Program when the game starts and the computer will attempt to load it into the game as a mod.  Since source code is not a runnable mod, errors will result.

I'm not sure as to ALL of the reasons for requiring the source code to be released, as I imagine that there are a fair few of them to be considered.  Some reasons that I myself can think of: it prevents some douchebag from designing a virus to look like a mod, since with the source code, it'll be very apparent that it's a virus; Squad itself might want to look into the code to see how it works.  Some mods have actually been absorbed into the stock game, and some modders have even been hired as programmers.  No lie.

Of course, since it's also a huge no-no to charge money for a mod, that means that anyone who makes a mod is doing it as a volunteer hobbyist.  Which means that they can quit at any time, such as when stuff gets real in their offline lives.  Making the code open source allows other volunteers (strangers) to take over support of the mod once the original author is no longer around to do it.

Link to comment
Share on other sites

4 hours ago, MisterFister said:

Of course, since it's also a huge no-no to charge money for a mod, that means that anyone who makes a mod is doing it as a volunteer hobbyist.  Which means that they can quit at any time, such as when stuff gets real in their offline lives.  Making the code open source allows other volunteers (strangers) to take over support of the mod once the original author is no longer around to do it.

Open Source is not the same thing as "includes sources". :)  Squad only requires the source to be available, not any particular license.

Several mods have been relegated to the dust bin of history because the license didn't allow anyone to continue it.  One famous example is ISA Mapsat, which the author licensed as "ALL RIGHTS RESERVED / No code is allowed to be used or modified and published without express written consent."  It was a cool mod, but after the author quit working on it, nobody else could legally continue it (despite having the source).  So, people started from scratch and made SCANsat.

Link to comment
Share on other sites

On 01/05/2016 at 9:04 PM, bobprime said:

If you wanted it to honor remote tech then there is no need to install it.  A craft without power can't run it's antennas and thus you would never be able to command the battery on.  Which is what stock does already.

I was thinking that this could account for low power mode. :P

Link to comment
Share on other sites

On 5/4/2016 at 6:27 AM, MisterFister said:

For the average end user like you or me, there's no use for it, because you need to be a programmer to understand it.  I suggest leaving it in the zipfile that you downloaded and just extracting the mod files into your GameData.  Again, whatever you do, DO NOT place the source code in your GameData folder -- anything in the GameData folder will be scanned by Kerbal Space Program when the game starts and the computer will attempt to load it into the game as a mod.  Since source code is not a runnable mod, errors will result.
 

Having text files (readmes, licence, source etc.) in the mod's GameData subfolder isn't harmful. KSP doesn't try to load it. You can unzip the download file as-is into GameData and it will run fine. The source is not necessary, but it isn't harmful either - it is treated just like any other text file.

Link to comment
Share on other sites

On 01/05/2016 at 7:04 AM, bobprime said:

If you wanted it to honor remote tech then there is no need to install it.  A craft without power can't run it's antennas and thus you would never be able to command the battery on.  Which is what stock does already.

This is incorrect. There is an option that will allow you to still control (point) antennas on unconnected craft in remote tech to attempt to re-establish connection. This abstracts probe behaviour in real life that has automated software that will attempt to find new connections if connection is lost. Real probes don't just "give up" and frequency scanning is by no means a new or novel approach. In many ways remote tech is more difficult then real life. 

Link to comment
Share on other sites

On 5/4/2016 at 0:27 AM, MisterFister said:

No.  The "source" is the human-readable programmed code of the mod.  The "mod" files are the compiled code, after they've been converted into information that is not human-readable but IS machine-readable.

Squad (the company that makes Kerbal Space program) allows anyone to create mods for the game, on the strictly-enforced condition that anyone who makes a mod also release the source code with it, or a description as to where it can be publicly found on the internet (such as a github or dropbox link.)  Releasing a mod without also releasing the source code is a HUGE no-no with this game, and people take it extremely-very seriously.

For the average end user like you or me, there's no use for it, because you need to be a programmer to understand it.  I suggest leaving it in the zipfile that you downloaded and just extracting the mod files into your GameData.  Again, whatever you do, DO NOT place the source code in your GameData folder -- anything in the GameData folder will be scanned by Kerbal Space Program when the game starts and the computer will attempt to load it into the game as a mod.  Since source code is not a runnable mod, errors will result.

I'm not sure as to ALL of the reasons for requiring the source code to be released, as I imagine that there are a fair few of them to be considered.  Some reasons that I myself can think of: it prevents some douchebag from designing a virus to look like a mod, since with the source code, it'll be very apparent that it's a virus; Squad itself might want to look into the code to see how it works.  Some mods have actually been absorbed into the stock game, and some modders have even been hired as programmers.  No lie.

Of course, since it's also a huge no-no to charge money for a mod, that means that anyone who makes a mod is doing it as a volunteer hobbyist.  Which means that they can quit at any time, such as when stuff gets real in their offline lives.  Making the code open source allows other volunteers (strangers) to take over support of the mod once the original author is no longer around to do it.

Thank you for your explanation. It was very informative. This community is great! Very friendly and helpful. Now time to go launch my next space telescope! This mod has been awesome so far. No more dead space craft once I return to them or come out of time warp! :D

Link to comment
Share on other sites

In the hope of helping in improving this mod, here is an excerpt from a log file showing some errors when loading a vessel with no batteries on it:

[EXC 16:29:28.002] NullReferenceException: Object reference not set to an instance of an object
    BatteryActivator.BatteryActivator.ChargeUnavailable ()
    BatteryActivator.BatteryActivator.drawGUI ()
    BatteryActivator.BatteryActivator.OnGUI ()

Link to comment
Share on other sites

10 hours ago, Galenmacil said:

In the hope of helping in improving this mod, here is an excerpt from a log file showing some errors when loading a vessel with no batteries on it:

[EXC 16:29:28.002] NullReferenceException: Object reference not set to an instance of an object
    BatteryActivator.BatteryActivator.ChargeUnavailable ()
    BatteryActivator.BatteryActivator.drawGUI ()
    BatteryActivator.BatteryActivator.OnGUI ()

Thanks for this. I will track it down for the next release. 

There will probably be a KSP 1.1.3 along fairly soon, and I doubt I will release the mod again before that. The NullReferenceException isn't a serious enough problem to make a patch for on its own.

Link to comment
Share on other sites

  • 5 months later...
21 hours ago, Skalou said:

Someone to revive this mod? one of my probe is in difficulty even with (usless)safety batteries with Ec:rolleyes:

i tiried "as it" on KSP 1.2 but it doesn't work (no button) and spamming exeption.

Hi, I will look at this on Monday. I hope it doesn't need more than a recompile with the new version. 

Link to comment
Share on other sites

17 hours ago, Skalou said:

I don't know but the whole ressource system has been updated no..

I think that is just the way that resources are drained from tanks and batteries. This mod is really all GUI - it just flips a flag on the batteries and I don't need to worry about how the stuff flows about. 

Anyway, a recompile seems to have worked. I haven't tested heavily, but the button appears when it should as far as I can tell. Enjoy!

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...