JustPaste.it

;/ Decompiled by Champollion V1.0.0
Source : AutomaticLightSwitchScript.psc
Modified : 2012-04-10 22:15:05
Compiled : 2012-04-10 22:25:24
User : M3rvin
Computer : PIPBOY
/;
scriptName AutomaticLightSwitchScript extends ObjectReference
{Controls a set of lights with a master enable parent marker with this script attached to turn on and off at the times of the day specified by the properties LightsOffTime and LightsOnTime}

;-- Properties --------------------------------------
float property LightsOffTime = 7.00000 auto
{The time at which lights should be turned off}
float property LightsOnTime = 18.0000 auto
{The time at which lights should be turned on}

;-- Variables ---------------------------------------

;-- Functions ---------------------------------------

float function GetCurrentHourOfDay() global
{Returns the current time of day in hours since midnight}

float Time = utility.GetCurrentGameTime()
Time -= math.Floor(Time) as float
Time *= 24 as float
return Time
endFunction

; Skipped compiler generated GotoState

; Skipped compiler generated GetState

function OnInit()

if AutomaticLightSwitchScript.GetCurrentHourOfDay() > LightsOffTime
self.GotoState("LightsOff")
else
self.GotoState("LightsOn")
endIf
endFunction

function RegisterForSingleUpdateGameTimeAt(float GameTime)
{Registers for a single UpdateGameTime event at the next occurrence of the specified GameTime (in hours since midnight)}

float CurrentTime = AutomaticLightSwitchScript.GetCurrentHourOfDay()
if GameTime < CurrentTime
GameTime += 24 as float
endIf
self.RegisterForSingleUpdateGameTime(GameTime - CurrentTime)
endFunction

;-- State -------------------------------------------
state lightson

function OnBeginState()

self.Enable(false)
self.RegisterForSingleUpdateGameTimeAt(LightsOffTime)
endFunction

function OnUpdateGameTime()

self.GotoState("LightsOff")
endFunction
endState

;-- State -------------------------------------------
state lightsoff

function OnBeginState()

self.Disable(false)
self.RegisterForSingleUpdateGameTimeAt(LightsOnTime)
endFunction

function OnUpdateGameTime()

self.GotoState("LightsOn")
endFunction
endState