Jump to content

Need Help with a script for auto color cycle lightboxes


pndr

Recommended Posts

I'm can read papyrus okay, but writing it is another story. I'm sure I have made a bunch of errors , so any help would be greatly appreciated. This script is based of the WorkshopLightboxScript that controls the build able light boxes.

 

 

 

 

Scriptname AdamTimer extends WorkshopLightboxScript



Event OnTimer(int aiTimerID)
If aiTimerID == cyclingTimerID
int cyclingType = GetValue(WorkshopLightboxCyclingType) as int
if cyclingType == 1
iNewColor = Utility.RandomInt(0, LightColors.Length - 1)
debug.trace(self + " pick random color " + iNewColor)
iNewBrightness = Utility.RandomInt(0, LightBrightness.Length - 1)
StartTimer(5)
EndIf
EndIf
EndEvent

function SetColor(int iColor = -1, int iBrightness = -1, bool bStopCycling = true)
if iColor == -1
iColor = GetValue(WorkshopTerminalLightColor) as int
endif
if iBrightness == -1
iBrightness = GetValue(WorkshopTerminalLightBrightness) as int
endif
; set cycling type to 0 - no cycling
if bStopCycling
SetCyclingType(0)
endif
String animString = GetAnimString(iColor, iBrightness)
if animString
; save color
SetValue(WorkshopTerminalLightColor, iColor)
SetValue(WorkshopTerminalLightBrightness, iBrightness)
debug.trace(self + " setting color to " + animString)
PlayAnimation(animString)
endif
endFunction


function SetCyclingTime(float cyclingTime)
if cyclingTime <= 0
; turn off
SetValue(WorkshopLightboxCycling, 0)
StartCycling(false)
else
SetValue(WorkshopLightboxCycling, cyclingTime)
StartCycling(true)
endif
endFunction

function SetCyclingType(int cyclingType)
SetValue(WorkshopLightboxCyclingType, cyclingType)
if cyclingType == 0
StartCycling()

endif
endFunction


function StartCycling(bool bStart = true)
;/
float cyclingTime = GetValue(WorkshopLightboxCycling)
if cyclingTime == 0
; get and set default value
cyclingTime = cylingTimeDefault
endif

if bStart && cyclingTime > 0
StartTimer(cyclingTime, cyclingTimerID)
else
; cancel timer
CancelTimer(cyclingTimerID)
endif
/;
endFunction

function CycleToNextColor()
int iCurrentColor = (GetValue(WorkshopTerminalLightColor) as int)
int iCurrentBrightness = (GetValue(WorkshopTerminalLightBrightness) as int)
iCurrentBrightness += 1
if iCurrentBrightness >= LightBrightness.Length
iCurrentBrightness = 0
iCurrentColor += 1
if iCurrentColor >= LightColors.Length
iCurrentColor = 0
endif
endif
SetColor(iCurrentColor, iCurrentBrightness, false)
endFunction

Edited by pndr
Link to comment
Share on other sites

  • Recently Browsing   0 members

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