Jump to content

How can I add a timer to a electrical switch?


BarbyFN

Recommended Posts

I have all my electrical switches working well with this script (taken from GECK tutorials) :

ScriptName A1SwitchLightScript

ref light

Begin OnActivate
	if light == 0
		set light to GetLinkedRef
	endif

	if light.GetDisabled
		light.Enable
	else
		light.Disable
	endif
	Activate
End

This script works fine, but the switches has "on/off" animations and if I activate too quick I can swap their animations (red turns when light is enabled and green when light is disabled). I like to add a way to prevent to quick activate them, I think is by adding a timer that force to wait a second after next activation, but maybe there is a better way.

Link to comment
Share on other sites

  • 2 weeks later...

Well, I finished my mod but I want to add good switches, I tried again by copying timers from others scripts to my light script but they didn't work, this was my best result but the switch stop working after its first activation...

ScriptName A1SwitchLightScript

ref Light
float Timer

Begin OnActivate
	if Light == 0 && Timer <= 0
		set Light to GetLinkedRef
		set Timer to 2
	else
		set Timer to Timer - GetSecondsPassed
		return
	endif

	if light.GetDisabled
		light.Enable
	else
		light.Disable
	endif
	Activate
End

not expert in scripting, I'm clueless.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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