Jump to content

[WIP] Solar Sensor Switch


cypher2012

Recommended Posts

Hey guys.

 

Currently working on a simple mod. It's a switch you can build in workshop mode, that activates/deactivates during day/night.

 

I've pretty much finished the scripting already. I'll make a few adjustments so you can have powered on during the day or night.

You can choose a pylon that is active during the day, or one that is active during the night.

 

This mod is aimed at somebody that for example, wants an easy way to have lights turn off during the day.

 

 

I've done some modelling.

 

Recycled the power pylon and modeled a little solar panel to it:

25299597_10155571924800129_370333640213325073375_10155571925090129_835857425542725075027_10155571925335129_416387942775625300051_10155571929035129_6143638093707

Edited by cypher2012
Link to comment
Share on other sites

cool!

this'll go great with Massigest and FiftyTifty's electronics parts,

better conditional logic switches etc.

 

hehe, i can even have your 'indiana jones'/'rollercoaster' be only online during daylight hours... hehe.

 

thanks Cypher2012!

I can't wait to see what you'll come up with next.

Link to comment
Share on other sites

Code for anybody thinking of doing something similar:

Scriptname SSS:SSS_SolarSwitch extends ObjectReference

float Property LightsOffTime = 7.0 auto
{The time at which lights should be turned off}
float Property LightsOnTime = 18.0 auto
{The time at which lights should be turned on}
Bool Property bNightActivated = True Auto Const
{If bNightActivated to true, power will be enabled at night. Reverse if set to false.}
 
float Function GetCurrentHourOfDay() global
{Returns the current time of day in hours since midnight} 
	float Time = Utility.GetCurrentGameTime()
	Time -= Math.Floor(Time) ; Remove "previous in-game days passed" bit
	Time *= 24 ; Convert from fraction of a day to number of hours
	Return Time
EndFunction

Function CheckIfStateChangeNeeded()
	StartTimer(10.0, 0)

	float fCurrentTime = GetCurrentHourOfDay()
	If (fCurrentTime > LightsOffTime && fCurrentTime < LightsOnTime)
		GoToState("DayTimeState")
	Else
		GoToState("NightTimeState")
	EndIf 
EndFunction

Event OnTimer(int aiTimerID)
	CheckIfStateChangeNeeded()	
EndEvent
 
Event OnInit() 
	CheckIfStateChangeNeeded()	
EndEvent
 
State NightTimeState 
	Event OnBeginState(string sOldState)
		if(bNightActivated)
			Self.SetOpen(false)
		else
			Self.SetOpen(true)
		endif
	EndEvent 
EndState
 
State DayTimeState 
	Event OnBeginState(string sOldState)
		if(bNightActivated)
			Self.SetOpen(true)
		else
			Self.SetOpen(false)
		endif
	EndEvent 
EndState


Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...