80 lines
2.2 KiB
Plaintext
80 lines
2.2 KiB
Plaintext
Scriptname _00E_Tavern_LightFXSwitcherSC extends ObjectReference
|
|
|
|
|
|
;=====================================================================================
|
|
; EVENTS
|
|
;=====================================================================================
|
|
|
|
Event OnCellAttach()
|
|
; Debug.Trace(self + ", OnCellAttach: start")
|
|
LightLinkerRef = GetLinkedRef() ; To speed up things in UpdateLightLinker a bit
|
|
EndEvent
|
|
|
|
Event OnTriggerEnter(ObjectReference akActionRef)
|
|
If akActionRef == PlayerREF
|
|
; Debug.Trace(self + ", OnTriggerEnter")
|
|
RegisterForSleep()
|
|
RegisterForModEvent("TimeSkip", "OnTimeSkip")
|
|
UpdateLightLinker()
|
|
EndIf
|
|
EndEvent
|
|
|
|
Event OnTriggerLeave(ObjectReference akActionRef)
|
|
If akActionRef == PlayerREF
|
|
UnregisterForSleep()
|
|
UnregisterForAllModEvents()
|
|
LightLinkerRef = None ; To not keep it persistent
|
|
EndIf
|
|
EndEvent
|
|
|
|
Event OnSleepStop(bool abInterrupted)
|
|
UpdateLightLinker()
|
|
EndEvent
|
|
|
|
Event OnTimeSkip(String eventName, String strArg, Float numArg, Form sender)
|
|
UpdateLightLinker()
|
|
EndEvent
|
|
|
|
|
|
;=====================================================================================
|
|
; FUNCTIONS
|
|
;=====================================================================================
|
|
|
|
float Function GetCurrentHourOfDay()
|
|
|
|
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 UpdateLightLinker()
|
|
; Debug.Trace(self + ", UpdateLightLinker")
|
|
|
|
If LightLinkerRef == None
|
|
LightLinkerRef = GetLinkedRef()
|
|
EndIf
|
|
|
|
Float fCurHour = GameHour.GetValue()
|
|
If fCurHour >= 18.5 || fCurHour < 5.9
|
|
If LightLinkerRef.IsEnabled()
|
|
LightLinkerRef.Disable()
|
|
EndIf
|
|
Else
|
|
If LightLinkerRef.IsDisabled()
|
|
LightLinkerRef.Enable()
|
|
EndIf
|
|
EndIf
|
|
EndFunction
|
|
|
|
|
|
;=====================================================================================
|
|
; PROPERTIES
|
|
;=====================================================================================
|
|
|
|
ObjectReference LightLinkerRef
|
|
|
|
Actor Property PlayerREF Auto
|
|
GlobalVariable Property GameHour Auto
|