Guest Messenjah Posted August 23, 2011 Share Posted August 23, 2011 Ok, so I wrote this script: SCN FFSuiteLightTimerSCRIPT REF SuiteLights Short DoOnce Float FFSLightTime Begin GameMode Set SuiteLights to GetLinkedRef Set FFSLightTime to FFSLightTime+GetSecondsPassed If player.GetInCell 000001NewClubSuite Set DoOnce to 0 If [FFSLightsTime > 1.5] && [DoOnce <= 0] SuiteLights.Enable 0 elseif [FFSLightsTime > 1.75] && [DoOnce <= 0] FSLights.Disable 0 Elseif [FFSLightsTime > 2.25] && [DoOnce <= 0] SuiteLights.Enable 0 Elseif [FFSLightsTime > 2.75] && [DoOnce <= 0] SuiteLights.Disable 0 Elseif [FFSLightsTime > 3] && [DoOnce <= 0] SuiteLights.Enable 0 Set DoOnce to 1 SuiteLights.Disable 0 Endif else Set DoOnce to 1 Endif End Ok, so what this script is supposed to do, is set up a set of lights, that when the player enters a specific cell, the script will wait 1.5 seconds, then flicker the lights twice and on the third try, the light will turn on. However, I only want it to do this one time upon entering the cell and I want the lights to disable when the player is not within the same cell. Any ideas on what I'm doing wrong? It won't save out. :\ Link to comment Share on other sites More sharing options...
Korodic Posted August 23, 2011 Share Posted August 23, 2011 (edited) im not 100% sure if this is the issue. but you are using "[ ]" when i think you need to use "( )" personally instead of setting suite lights to link ref each other I would use an Xmarker for a parent, and then make the X marker the parent for all of the lights. Then you can enable/disable the x marker for your lights to turn on/off. EDIT: what does ".disable 0" do? I've never done it like that either. I always do a simple ".disable" Edited August 23, 2011 by Skibblets Link to comment Share on other sites More sharing options...
Guest Messenjah Posted August 23, 2011 Share Posted August 23, 2011 That is exactly what this script does. Sorry, I forgot to mention that. The xmarker controls the lights. I did get it to save now but nothing happens. :\ Any thoughts? SCN FFSuiteLightTimerSCRIPT REF SuiteLights Short DoOnce Float TimeVar Begin GameMode Set SuiteLights to GetLinkedRef Set DoOnce to 0 Set TimeVar to TimeVar + GetSecondsPassed If player.GetInCell 000001NewClubSuite Set DoOnce to 0 If [TimeVar >= 1.5] && [TimeVar < 1.75] && [DoOnce == 0] SuiteLights.Enable 0 Elseif [TimeVar >= 1.75] && [TimeVar < 2.25] && [DoOnce == 0] SuiteLights.Disable 0 Elseif [TimeVar >= 2.25] && [TimeVar < 2.5] && [DoOnce == 0] SuiteLights.Enable 0 Elseif [TimeVar >= 2.5] && [TimeVar < 2.75] && [DoOnce == 0] SuiteLights.Disable 0 Elseif [TimeVar >= 3] [DoOnce == 0] SuiteLights.Disable 0 Set DoOnce to 1 Endif else Set DoOnce to 1 Endif End Link to comment Share on other sites More sharing options...
Korodic Posted August 23, 2011 Share Posted August 23, 2011 (edited) Try this... Also... tyou'll noticed i flipped values on DoOnce. Why? Because DoOnce defaults (meaning the second you declare the variable is is equal) to 0. This looks a little better. This change alone may fix it. Oh! I see you are missing the == 1 in your "player.GetInCell 000001NewClubSuite" This should be the issue. SCN FFSuiteLightTimerSCRIPT REF SuiteLights Short DoOnce Float TimeVar Set SuiteLights to GetLinkedRef Begin GameMode Set TimeVar to TimeVar + GetSecondsPassed If [player.GetInCell 000001NewClubSuite == 1] Set DoOnce to 1 endif If [TimeVar >= 1.5] && [TimeVar < 1.75] && [DoOnce == 1] SuiteLights.Enable 0 Elseif [TimeVar >= 1.75] && [TimeVar < 2.25] && [DoOnce == 1] SuiteLights.Disable 0 Elseif [TimeVar >= 2.25] && [TimeVar < 2.5] && [DoOnce == 1] SuiteLights.Enable 0 Elseif [TimeVar >= 2.5] && [TimeVar < 2.75] && [DoOnce == 1] SuiteLights.Disable 0 Elseif [TimeVar >= 3] [DoOnce == 1] SuiteLights.Disable 0 Set DoOnce to 0 Endif End Edited August 23, 2011 by Skibblets Link to comment Share on other sites More sharing options...
Cipscis Posted August 24, 2011 Share Posted August 24, 2011 If I remember correctly, square brackets work in the same way as rounded brackets in Fallout scripts. Both Enable and Disable have an optional "fadeIn" or "fadeOut" parameter. For Enable, the default value is 1, and for Disable it is 0. This means that "Disable 0" is the same as "Disable", as the parameter's value is the same as it would be by default. GetInCell, like all functions that can only return 0 or 1, doesn't need "== 1" when checking it in a condition. Either it returns 0, then "0 == 1" also returns 0, or it returns 1 then 1 == 1" also returns 1. Adding "== 1" doesn't change the result in any case, but it does add an extra comparison and, with it, slightly decreases the script's efficiency. Of course, that alone won't affect performance, but it's useful to be aware of such things. If you're interested, I've written a tutorial on a type of script I call a "staged timer" that is very useful for things just like this. Here's a link - Staged Timers Cipscis Link to comment Share on other sites More sharing options...
Korodic Posted August 24, 2011 Share Posted August 24, 2011 Well thank you for answering my question and all... but did you answer the OP's? :armscrossed: lol Link to comment Share on other sites More sharing options...
Cipscis Posted August 24, 2011 Share Posted August 24, 2011 The link to my tutorial was for Messenja (although obviously I'd like others to read it as well), although reading my post again now I can see how that could have been unclear. I'm posting from a mobile device at the moment, so reviewing scripts is more difficult for me than it would usually be. Cipscis Link to comment Share on other sites More sharing options...
Guest Messenjah Posted August 24, 2011 Share Posted August 24, 2011 Ah, after a few times reading it, I understand, you are staging the timer by first checking the condition of the timer (what time it is) and then telling it to go to the next step by setting it? Although, wouldn't that cause the timer to "skip" seconds? As you may notice, my timer varies. It will have a .25 second pause for the light flicker itself and a .5 pause between each flicker of the light. Also the enable 0/disable 0, the 0 and 1 would be a variable used for a fade-in effect. It basically tells the script if you want it to fade in or not. Actually, if it IS set to 0, it will not fade out. This is a flickering effect so it would look odd if the light had a fade in/out effect. I want it to have a popping effect instead. Also, adding a == 1 statement to getincell, only checks to see if the player is in-fact inside the cell. However, this is the default, so I didn't bother with it. To be honest, I'm not sure which would be more efficient because I want to make sure that my script is read correctly and not misunderstood by the game engine, so asking it to make that additional check may also ensure that it won't bug out. Also, this script is attached to a generic activator, if that may have any effect on the issue? It appears that it just isn't playing at all at this point. Also, I tried fixing my script with the modifications you listed, Skibblets, but it still isn't working. I simply don't get anything to initialize, at least it appears that way. :\ The idea, is that the scripted animation sequence will only play if the player is located inside the cell and will not play if the player is outside of the cell. Additionally, I want the script to only play once and stop when the player is located in the cell as well. Link to comment Share on other sites More sharing options...
Korodic Posted August 24, 2011 Share Posted August 24, 2011 SCN FFSuiteLightTimerSCRIPT REF SuiteLights Short DoOnce Float TimeVar short DoCode Set SuiteLights to GetLinkedRef Begin GameMode IF ( DoCode == 1 ) Set TimeVar to TimeVar + GetSecondsPassed If [TimeVar >= 1.5] && [TimeVar < 1.75] && [DoOnce == 1] SuiteLights.Enable 0 Elseif [TimeVar >= 1.75] && [TimeVar < 2.25] && [DoOnce == 1] SuiteLights.Disable 0 Elseif [TimeVar >= 2.25] && [TimeVar < 2.5] && [DoOnce == 1] SuiteLights.Enable 0 Elseif [TimeVar >= 2.5] && [TimeVar < 2.75] && [DoOnce == 1] SuiteLights.Disable 0 Elseif [TimeVar >= 3] && [DoOnce == 1] SuiteLights.Disable 0 Set DoOnce to 0 Set DoCode to 0 Endif Endif End Begin OnActivate If [player.GetInCell 000001NewClubSuite == 1] Set DoOnce to 1 Set DoCode to 1 endif END Try this. Since you are using an activator. Not sure how much of a difference this will make, but whenever I use activators I always use Onactivate. If the above code doesn't work... on your first try try it the other way around.... SCN FFSuiteLightTimerSCRIPT REF SuiteLights Short DoOnce Float TimeVar short DoCode Set SuiteLights to GetLinkedRef Begin OnActivate If [player.GetInCell 000001NewClubSuite == 1] Set DoOnce to 1 Set DoCode to 1 endif END Begin GameMode IF ( DoCode == 1 ) Set TimeVar to TimeVar + GetSecondsPassed If [TimeVar >= 1.5] && [TimeVar < 1.75] && [DoOnce == 1] SuiteLights.Enable 0 Elseif [TimeVar >= 1.75] && [TimeVar < 2.25] && [DoOnce == 1] SuiteLights.Disable 0 Elseif [TimeVar >= 2.25] && [TimeVar < 2.5] && [DoOnce == 1] SuiteLights.Enable 0 Elseif [TimeVar >= 2.5] && [TimeVar < 2.75] && [DoOnce == 1] SuiteLights.Disable 0 Elseif [TimeVar >= 3] && [DoOnce == 1] SuiteLights.Disable 0 Set DoOnce to 0 Set DoCode to 0 Endif Endif End Link to comment Share on other sites More sharing options...
Guest Messenjah Posted August 24, 2011 Share Posted August 24, 2011 Yes but it isn't intended to work as an activator, it should run constantly, that is what Begin GameMode is for, is it tells the script to run every frame. This is why there is a DoOnce block, so that it stops the script. If it is OnActivate, it will only run when the player interacts with the activator. Also, when you run this: Set SuiteLights to GetLinkedRef Never place that in the reference block, always put a set script after the begin block. :) Couldn't get your script to save for a while until I noticed that little error. Anyway, I have a light sequence script for a set of stage lights in another script and it works with a Begin GameMode when attached to an activator so it SHOULD work and you should never need an OnActivate script. Link to comment Share on other sites More sharing options...
Recommended Posts