numbhandz Posted May 10, 2010 Share Posted May 10, 2010 Hi Guys. I'm having trouble creating a script for an activator to switch on some lights at different intervals. I have attached a pic to show what I am trying to achieve. All the lights are persistent and set to be initially disabled. I'm a total noob at scripting, so any help showing me what this script should look like will be greatly appreciated.Thanks. EDIT: This is how far I have gotten with the script. It works perfectly in the GameMode block but as soon as I change it to onActivate nothing happens. What do I have to do to get it to work on an Activator? ScriptName TimedLightsTest float Timer short sLight01 short sLight02 short sLight03 begin GameMode if sLight01 == 0 set Timer to 0.5 set sLight01 to 1 else if Timer > 0 set Timer to Timer - GetSecondsPassed else if Timer < 0.1 light01.enable if sLight02 == 0 set Timer to 0.5 set sLight02 to 1 else if Timer > 0 set Timer to Timer - GetSecondsPassed else if Timer < 0.1 light02.enable if sLight03 == 0 set Timer to 0.5 set sLight03 to 1 else if Timer > 0 set Timer to Timer - GetSecondsPassed else if Timer < 0.1 light03.enable endif endif endif endif endif endif endif endif endif end Link to comment Share on other sites More sharing options...
BadPenney Posted May 11, 2010 Share Posted May 11, 2010 I think that this might work: ScriptName TimedLightsTest float Timer short sLight01 short sLight02 short sLight03 short DoOnce begin OnActivate if doOnce == 0 activate set Timer to 1.5 set doOnce to 1 if Timer > 0 set Timer to Timer – GetSecondsPassed endif if Timer < 1 && sLight01 == 0 && doOnce == 1 Light01.enable set sLight01 to 1 elseif Timer < 0.5 && sLight02 == 0 && doOnce == 1 Light02.enable set sLight02 to 1 elseif Timer <= 0 && sLight03 == 0 && doOnce == 1 Light03.enable set sLight03 to 1 endif elseif doOnce == 1 activate set doOnce to 0 Light01.disable Light02.disable Light03.disable set sLight01 to 0 set sLight02 to 0 set sLight03 to 0 endif end I think that this should cause the lights to come on in the timed sequence that you want when the switch is activated and the lights are off. If the switch is activated again with all of the lights on, then they will all shut off at the same time. You could also use the same sort of timer to make them shut off in stages instead. If you don't want the switch to toggle the lights on and off but only come on once then just remove the last bit that disables them when doOnce == 1. Link to comment Share on other sites More sharing options...
Dyadya_Fedor Posted May 11, 2010 Share Posted May 11, 2010 In script above missing GameMode block I changed code a littleScriptName TimedLightsTest float Timer short Stage begin onactivate if Stage == 0 set Stage to 1 set Timer to 1.5 activate elseif Stage == 4 ;if you want to turn lights of before sequence is complete replace with "else" activate set Stage to 0 Light01.disable Light02.disable Light03.disable endif end Begin GameMode if Timer > 0 set Timer to Timer – GetSecondsPassed endif if Stage == 1 && Timer < 1 Light01.enable set Stage to 2 elseif Stage == 2 && Timer < 0.5 Light02.enable set Stage to 3 elseif Stage == 3 && Timer <= 0 Light03.enable set Stage to 4 endif end Link to comment Share on other sites More sharing options...
numbhandz Posted May 11, 2010 Author Share Posted May 11, 2010 I copied your scripts but had to tweak it a little bit in order for it to work. I'm so happy that everything works as intended now. Thanks BadPenney && Dyadya_Fedor for your help. ScriptName TimedLightsTest float Timer short sLight short Stage begin onactivate if Stage == 1 set Stage to 2 Activate elseif Stage == 3 activate set Stage to 0 Light01.disable Light02.disable Light03.disable set sLight to 0 endif end begin GameMode if Stage == 0 set Timer to 1.5 set Stage to 1 endif if Stage == 2 && Timer > 0 set Timer to Timer - GetSecondsPassed if Timer < 1 && sLight == 0 Light01.enable set sLight to 1 elseif Timer < 0.5 && sLight == 1 Light02.enable set sLight to 2 elseif Timer <= 0 && sLight == 2 Light03.enable set Stage to 3 endif endif end Link to comment Share on other sites More sharing options...
Recommended Posts