RimWorld

RimWorld

674 ratings
PowerSwitch
   
Award
Favorite
Favorited
Unfavorite
Mod, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5
File Size
Posted
Updated
1.014 MB
Jul 4, 2016 @ 2:57pm
Jun 14, 2024 @ 2:31pm
35 Change Notes ( view )

Subscribe to download
PowerSwitch

Description
This mod adds additional functions to the vanilla power switch.

Here you have various research topics available, which will improve the functionality of the switch.
You can research the upgrade for a motion detector, an enemy detector and for a timer.


Note: Mod settings are available.


Description:

- Pawn Detection in Room: Available after research with the normal switch.
Detects if a Pawn (human, animal) is in the room

- Pawn Detection within 7 squares: Available after research.
Normal pawn detection mode for wall switches.
Normal switches can be switched between this mode and the pawn in room mode by repeatedly pressing the selection button.

- Enemy detection (within 1/2 of the map): Available after research.
Available modes: Switch on when detected and switch off when detected.

- Timer: Switches on and off at specified times.
Time is initially set to 6h->On and 20h->Off. This can be changed by pressing the buttons repeatedly



NOTE:
This mod can savely be added to a running savegame, but to use the functionality you have to destroy and rebuild (by debug mode or the normal way) the switches you already have, as the old ones don't have the needed references.


(Version: 1.5.0)
Language: English, German, Russian, Chinese, Spanish

Thanks to duduluu and Biscuit for the Chinese translation
Thanks to 53N4 for the Spanish translation
Thanks to Well for the Russian translation
260 Comments
Haplo_X1  [author] May 8 @ 11:53am 
You can do a pull request if you like, then I can merge it
Scentese May 6 @ 7:40am 
Haplo_X1, should I make a push/fork/anything? All the code changes are just one block and one line. And thank you for the great mod!
Scentese May 6 @ 7:36am 
also add this in your class scope (outside of the method) if anyone is using the fix

private int lastCheckedHour = -1;
Scentese May 6 @ 7:33am 
I was using this mod along with Logic Switch. I am not sure if it resulted in any conflict, but this fix seems to have made the timer of this mod work for me, by flicking the switch only once per hour. The timer may not start to work immediately, but should do after an hour of in game time.
Scentese May 6 @ 7:33am 
with

[code]
// Improved Timer switching
if (autoSwitchTimerActive)
{
int currentHour = GenLocalDate.HourInteger(Map);

if (currentHour != lastCheckedHour)
{
lastCheckedHour = currentHour;

if (currentHour == autoSwitchTimerOnTime && !flickableComp.SwitchIsOn)
{
flickableComp.SwitchIsOn = true; // No designator usage!
SetWantSwitchOn(true);
}

if (currentHour == autoSwitchTimerOffTime && flickableComp.SwitchIsOn)
{
flickableComp.SwitchIsOn = false; // No designator usage!
SetWantSwitchOn(false);
}
}
}
[/code]
Scentese May 6 @ 7:32am 
ok I might have made a fix:

replace
[code]
// Timer switching
if (autoSwitchTimerActive)
{
// Time = Off-Time => Switch OFF
if (GenLocalDate.HourInteger(Map) == autoSwitchTimerOffTime && flickableComp.SwitchIsOn)
{
flickableComp.SwitchIsOn = false; // No designator usage!
SetWantSwitchOn(false);
}

// Time = On-Time => Switch ON
if (GenLocalDate.HourInteger(Map) == autoSwitchTimerOnTime && !flickableComp.SwitchIsOn)
{
flickableComp.SwitchIsOn = true; // No designator usage!
SetWantSwitchOn(true);
}
}
[/code]
Scentese Apr 25 @ 9:30pm 
I too feel the timer function is buggy. Could you please link the repo of 1.5 for me to take a look at?
123caboom Apr 8 @ 9:03am 
Compatible to the wall mounted switch in „hold my switch“?
Shabazza Jan 11 @ 2:11pm 
Timer function is not working for me. It always stays on.