BarbyFN Posted May 8, 2014 Share Posted May 8, 2014 (edited) I attempted to modify the autoclose door script from this tutorial to work with a light switch, but it doesn't work. This is my modification: scn AutoClosingScript ref light float LightTimer Begin GameMode if LightTimer > 0 set LightTimer to LightTimer - getSecondsPassed elseif LightTimer == 0 Light.Disable endif endif End Begin OnActivate set light to GetLinkedRef if light.GetDisabled light.Enable set LightTimer to 60 else light.Disable set LightTimer to 0 endif Activate End I don't know even if the script works because I can't test it at all, in game the switch that has this script disappear, it get disabled for some reason. What am I doing wrong? Edited May 8, 2014 by BarbyFN Link to comment Share on other sites More sharing options...
BarbyFN Posted May 9, 2014 Author Share Posted May 9, 2014 I forgot to say that I want to be able to turn the lights on and off at any time, instantly, but if I forgot the lights on, I wish that they turns off itself after a period of time. I am stuck with this... Link to comment Share on other sites More sharing options...
Deleted1205226User Posted May 9, 2014 Share Posted May 9, 2014 Sorry not being able to do more, atm, than posting a few links. They may not be exactly what you looking for, but it might help you somehow.http://www.cipscis.com/fallout/tutorials/staged_timers.aspxhttp://forums.nexusmods.com/index.php?/topic/139414-need-help-scripting-a-timed-sequence/http://forums.nexusmods.com/index.php?/topic/202761-delayed-lights-script-help/ Link to comment Share on other sites More sharing options...
BarbyFN Posted May 10, 2014 Author Share Posted May 10, 2014 (edited) Thank you, those links were useful to understand more about stages and I managed to get it work as I said: I can turn on and off the lights by activating the switch at any time, but, if I forgot the lights on, passed “5 seconds” they turns off themselves. The only problem is that when I load the cell I have those “5 seconds” to activate the switch before the switch ‘disappears’ itself and never appears again. If I load the cell and run to quickly activate the switch, the rest of the game works like a charm, but if I wait those “5 seconds” the switch get disabled in front of my and I can’t understand why. I have this elements:-A light flagged as “initially disabled” and “persistent reference”-An activator (electrical switch) which has the script and linked reference to the light.-This script: scn SwitchAutoOffScript ref Light int Stage float Timer Begin OnActivate set Light to GetLinkedRef if Light.GetDisabled Light.Enable set Timer to 5 set Stage to 0 else Light.Disable set Timer to 0 set Stage to 2 endif Activate End Begin GameMode if Timer > 0 set Timer to Timer - getSecondsPassed elseif Stage == 0 set Timer to 5 Light.Enable set Stage to 1 elseif Stage == 1 if Timer > 0 ; do nothing else timer == 0 Light.Disable set Stage to 2 Activate endif Elseif Stage == 2 ; do nothing endif EndWhat could be wrong? Edited May 10, 2014 by BarbyFN Link to comment Share on other sites More sharing options...
Deleted1205226User Posted May 10, 2014 Share Posted May 10, 2014 Is your switch linked to the light or is it the other way around ?Is your activator set as persistent Ref ? Link to comment Share on other sites More sharing options...
BarbyFN Posted May 10, 2014 Author Share Posted May 10, 2014 Yes, the activator has all checkboxes unchecked, and is linked to the light in the section “Linked Ref”. The light is not linked at all; the only changes are the checkboxes “Persistent Reference” and “Initially Disabled” checked. For the other question: The activator was not set as persistent ref, but I check it as persistent and nothing changes. I don’t know why the activator gets disabled itself; it is the carrier of the script but the script did not make reference to it (except the line “Activate” that triggers the animation, I also remove this line to test but happens the same)... The most strange is that if I hurry up to quickly activate it after loading the cell, then the activator did not banished and all script works perfect as I said, the only instance in what the activator get disabled (passed xx seconds of the script) is the first time I load the cell. I’m stuck with this... Link to comment Share on other sites More sharing options...
Deleted1205226User Posted May 11, 2014 Share Posted May 11, 2014 Sorry, I'm very far from an expert, so I have no real answer. But I can search with you like I would do for myself : by questionning and by trial & errors. - What happen if you take out the two lines about timer in your OnActivate block ?- There are two lines where you set the timer to 5, to see wich one is problematic, I would change one (then the other) to say 10 and see if it changes the time before the switch disappear. Or, hopefully, some qualified person will come and spot the problem... Link to comment Share on other sites More sharing options...
vforvic Posted May 11, 2014 Share Posted May 11, 2014 Just off the top of my head, without testing it all myself, I have a couple of ideas.First, I would try making that "else timer == 0" near the end an "elseif" statement. Second, unless you need the timer for some reason, try using a "getdistance" function in the script instead or maybe a "GetInCell" function depending on your exact situation and desire. This way the light would disable when you are a certain distance from the light or if you left the interior cell itself. Link to comment Share on other sites More sharing options...
BarbyFN Posted May 12, 2014 Author Share Posted May 12, 2014 Well, after having placed a switch without linked reference I noticed that on activation the switch disappears too, so, that was the cause to my switch disappears at cell loading! Ha, it was really stupid but has given me two solutions: One is to move the line “set Light to GetLinkedRef” from the “OnActivate” to the “GameMode” block. This is the best general solution to use the script in more than one activator. The second is simply remove the entire line and its reference “Light”, replacing them straight for the Reference name itself; this script is 2 lines shorter but I think is better the first one because it leaves the possibility to use the same script in more than one activator if needed. This is the script fixed and working: scn SwitchAutoOffScript ref Light int Stage float Timer Begin OnActivate if Light.GetDisabled Light.Enable set Stage to 0 else Light.Disable set Stage to 1 endif Activate End Begin GameMode set Light to GetLinkedRef if Timer > 0 set Timer to Timer - getSecondsPassed elseif Stage == 0 set Timer to 60 set Stage to 1 elseif Stage == 1 if Timer > 0 ; do nothing else Light.Disable set Stage to 2 Activate endif elseif Stage == 2 ; do nothing endif End I must thank you the advices that makes me see the problem from different perspectives. Pixelhate, removing lines helps me to improve the script, making it smaller, and Vforvic your idea to use “getdistance” could be ideal, but in my case I will use this to a practice reflector and it isn't an important light, also the timer leaves me the ‘sensation’ of real timed clocks. Link to comment Share on other sites More sharing options...
Deleted1205226User Posted May 12, 2014 Share Posted May 12, 2014 I'm glad you've found the solution ! :) Link to comment Share on other sites More sharing options...
Recommended Posts