Jump to content

Need Help Scripting a Timed Sequence!


MrFisse

Recommended Posts

Hi everyone, new to this site. Played fallout 3 and its predecessors alot. Now i decided to make a mod of my own, a way to say thanks and trying to contribute back to all you out there that has made terrific mods for Fallout 3 and enhancing the game experience tenfolds!

 

Dont know if its really a mod im making really, its actually a pretty large player homevault :)

There are hundreds of houses available i know but since it feels like it was the easist to do since its my first modding attempt.

Anywho to the problem. Ive searched the forum and the Geck site and also google, found a couple of tutorials regarding scripting but they were pretty short and i didnt manage to get it to work even with the help from them.

 

Ive managed to create simple scripts like on / off scripts for lights etc. But now i want a couple of lights to switch on one after another in a timed sequence after the button is pressed. And when you press the button again i would like them to switch off on the same time (not in a sequence i.e). Dont know if this is even possible but i really hope so. Would make for quite som atmosphere in my vault.

 

Ive played around with three test glow statics just for testing purpose. Theese are named "one", "two" and "three" the swtich is named "TestSwitch" and is an activator. All objects are "Persistent Reference" enabled.

 

I modified the script that acts as the on/off switch script (wich works as it should)

 

ScriptName SequenceSwitchTEST

 

float fTimer

int iStage

short onoff

 

Begin OnActivate

 

 

 

 

if fTimer > 0

set fTimer to fTimer - GetSecondsPassed

elseif iStage == 0

 

Set onoff to "one".getDisabled

if onoff == 1

"one".Enable

 

Endif

 

 

set iStage to 1

set fTimer to 3

elseif iStage == 1

Set onoff to "one".getDisabled

if onoff == 1

"two".Enable

endif

set iStage to 2

set fTimer to 1

elseif iStage == 2

 

Set onoff to "one".getDisabled

if onoff == 1

"three".Enable

endif

 

If onoff ==0

"one".Disable

"two".Disable

"three".Disable

endif

endif

End

 

 

 

Is this all to hell wrong ? I might add that i have no prior programing language experience, hope someone is willing and have the time to help me out here a little :)

Peace all of you and thanks for all the mods !

Link to comment
Share on other sites

You need to add a Begin GameMode. Gamemode is run every frame where other block types are usually done once on a certain event. So what you should do is set a variable to 1 inside your OnActivate block, and have your Gamemode block check if that variable is 1 where it would then run the script.
Link to comment
Share on other sites

Thanks for the speedy reply, i tried some variants with it now but cant seem to get it right at all, dont even want to save the script? Where should i place it, again im a totally lost with this stuff :/

Maybe bit of more than i can chew it seems.

 

 

Edit:

 

Tried this and got it to save. Something happends now atleast. "One" turns on, a second pass and then "Three" turns on and "One" turns off :S Not quite what i was looking for. And when i try to turn of the lights again "three" just resets. I.E it disables and then enables instantly again. Maybe this entire script is all wrong :(

 

 

ScriptName LightSwitchScriptTEST

 

float fTimer

int iStage

short onoff

 

Begin OnActivate

Set onoff to "one".getDisabled

if onoff == 1

"one".Enable

Endif

 

end

 

Begin GameMode

if fTimer > 0

set fTimer to fTimer - GetSecondsPassed

elseif iStage == 0

 

 

 

 

set iStage to 1

set fTimer to 3

elseif iStage == 1

Set onoff to "one".getDisabled

if onoff == 1

"two".Enable

endif

 

 

set iStage to 2

set fTimer to 1

elseif iStage == 2

 

Set onoff to "one".getDisabled

if onoff == 1

"three".Enable

 

 

endif

If onoff ==0

"one".Disable

"two".Disable

"three".Disable

endif

endif

End

Link to comment
Share on other sites

Noone with any idea of how this should look to work ? Pleeeaaase :) Im starting to get crazy over this.

Using the time sequence in an OnActivate box dont seem to work and placing them in a Gamemode box just makes it start by itself without having to press the switch first.

Link to comment
Share on other sites

Please enclose code within "code" or "codebox" tags. This makes it much easier to read as it preserves indentation and causes the code to be displayed in a fixed-width font. If you don't know how to indent your code, here is a web-based tool that can do it for you, while checking your script for several structural errors - Script Validator

 

Looking at the names of your variables, particularly "fTimer" and "iStage", I'm guessing that you've had a look at my tutorial on Staged Timers? If you have a look at the last paragraph, you'll see that you can prevent a staged timer from running automatically if you set the value of the first stage to 1. The reason for this is that whenever you declare a variable, it is automatically intialised to a value of 0, so if it needs to be set to 1 before the first stage runs then you can delay the events until you're ready for them to be triggered.

 

I'm not entirely certain what effect you're looking for, but for the moment I'll take a guess and say that you want the three lights to be enabled one by one when the switch is first activated, and all switched off when it is activated again? If so, try using code like this:

ScriptName LightSwitchScriptTEST

float fTimer
int iStage
; 0 - All lights disabled
; 1 - Enable first light
; 2 - Enable second light
; 3 - Enable third light
; 4 - All lights enabled
; 5 - Disable all lights

int bState

Begin OnActivate

if iStage == 4
	set iStage to 5
elseif iStage
else ; if iStage == 0
	set iStage to 1
endif

End

Begin GameMode

if fTimer > 0
	set fTimer to fTimer - GetSecondsPassed
elseif iStage == 1
	set iStage to 2
	set fTimer to 3
	FirstLightREF.Enable
elseif iStage == 2
	set iStage to 3
	set fTimer to 1
	SecondLightREF.Enable
elseif iStage == 3
	set iStage to 4
	ThirdLightREF.Enable
elseif iStage == 5
	FirstLightREF.Disable
	SecondLightREF.Disable
	ThirdLightREF.Disale
endif

End

Note that because neither Enable nor Disable have been given parameters, the lights will "fade in" and "pop out".

 

Cipscis

Link to comment
Share on other sites

Thanks a thousand times ! Will try it out tomorrow and try to get some knowledge from the code.

Time to jump into bed, work tomorrow. Hard to tear yourself from the GECK >_>

 

The effect im looking for will be something like i have an alleyway and i have placed lights on both sides of the wall with a bit of spacing. When the switch is turned on the first set will go on, and a few seconds later the next pair will go in untill all of them are lit.

 

Got another problem with GECK/Fallout3 now been trying to find a solution all night, seems like my "glow" effects isnt showing up very well ingame. In the GECK they are bright as hell but in the game they are barely visible. Very strange. With glow effects i mean the statics that creates the sensation of the room being a bit smokey around light sources. Think its called light arches or something like that. Running everything on max ingame still dont show up as they should. Dont know if its because i messed around with the Ambient lighting etc for the CELL. They were visible before...

 

Anyways thanks again for the help and the code ! Much appriciated!

Link to comment
Share on other sites

That sounds really cool. Nice ambience for a room. IF you make a quest mod doing some similar lighting tricks with some sound efects could add a certain creepiness as well. Oh the possibilities.

 

I've only used lighting in game a little bit myself so I'm not great with that, but when I get back home I'll see if I have the same issue as you and look for a workaround. If Cipscis doesn't beat me to it again! :) Haha

Link to comment
Share on other sites

I solved the issue a couple of minutes ago, i somehow managed to remove the emitance for all my arches and illuminance effects. Reapplied them to all lights and now it looks great again.

Yes palasprince that sounds awesome, gonna wait with the quest writing though until this project is finished :)

I think lighting is one of the funniest aspects of creating Cells, im just afraid to use to much lighting. Might become heavy on peoples computers. And i don't think i will notice it myself since i have a pretty powerful system.

 

Gonna put up some WIP screens tomorrow i think. Its actually looking pretty sweet for being my first mod. Nice atmosphere down there :)

Link to comment
Share on other sites

  • Recently Browsing   0 members

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