Making an airlock

Post » Wed Jan 12, 2011 1:51 pm

SOLVED


http://www.gamesas.com/index.php?/topic/1067015-scripting-questions/page__view__findpost__p__15504216

I'm only concerned about the door timers though.

---------------------------------Entry    |1|        |2|---------------x-----------------


Door 1 is open by default, Door 2 isn't. x is the switch that toggles the state of both doors so when you walk in door 1 will close before door 2 can open. I've got this part working, but both doors activate at the same time. So I tried using the VaultDOORscript but all that does is delay both doors and they still open together. What I need is something that works like this;

1. When the switch is activated it would probably be a good idea to lock it out for 12 seconds until it can be used again.
2. If Door 1 is open, close immediately. If Door 1 isn't closed, wait 10 seconds and then make it open.
3. If Door 2 is open, close immediately. If Door 2 isn't closed, wait 10 seconds and then make it open

Below is my attempt at translating this into something the game can use. I bet I've missed something (please help if you can)

scn ContDoorScriptfloat timerBegin Onactivate   if isactivated == 0       set isactivated to 1   endifendBegin GameMode   if isactivated == 1 ;If the switch is activated, qualify the following conditions:      elseif          Door1.GetOpenState == 1 ;If door1 is open         Door1.SetOpenState 0 ;close it immediately         Door 2.GetOpenState ==1; If door2 is open         Door2.SetOpenState 0 ;close it immediately   endif   elseif      elseif          Door1.GetOpenState == 0 ;If door1 is closed         if timer > 10 ;and 10 seconds have passed,         Door1.SetOpenState 1 ;open door1.         Door2.GetOpenState == 0 ;If door2 is closed         if timer > 10 ;and 10 seconds have passed,         Door2.SetOpenState 0 ;open door2.      endif   endifend

User avatar
sas
 
Posts: 3435
Joined: Thu Aug 03, 2006 8:40 am

Post » Wed Jan 12, 2011 7:50 am

Thats a very odd way of doing it. How about this. Does the player HAVE to come from only one direction initally? If so do this. Simply have two switches. Switch1, and Switch2. Make Switch2 initially disabled, and Switch1 enabled. Place them in the exact same spot. (EXACTLY over eachother) Have door1 open by default, and door2 closed. Put this script on Switch1, it should be much simpler.

scn Switch1Scriptshort Busyfloat timerBegin OnActivate Player If Busy == 0  Set Busy to 1  Set Timer to 10  Door1ref.SetOpenState 0 EndIfEndBegin GameMode If Busy == 1  If Timer > 0   Set Timer to Timer - GetSecondsPassed  Else   Door2Ref.SetOpenState 1   Set Busy to 0   Switch1ref.disable   Switch2ref.enable 0  Endif EndifEnd


The on Switch2 (for coming back the other way) put this script. It simply swaps all script parts on Door1 for Door2, and Switch1 for Switch2. So...

scn Switch2Scriptshort Busyfloat timerBegin OnActivate Player If Busy == 0  Set Busy to 1  Set Timer to 10  Door2ref.SetOpenState 0 EndIfEndBegin GameMode If Busy == 1  If Timer > 0   Set Timer to Timer - GetSecondsPassed  Else   Door1Ref.SetOpenState 1   Set Busy to 0   Switchref.disable   Switch1ref.enable 0  Endif EndifEnd


The result is the door closes, then 10 seconds later the other opens. That should work for both switches, and the player could not activate them again while the 10 seconds closing/opening sequence is happening. Hope this helps. :D

Gunmaster95
User avatar
Kelly James
 
Posts: 3266
Joined: Wed Oct 04, 2006 7:33 pm

Post » Wed Jan 12, 2011 11:21 am

Your both making it more difficult than necessary. You only need one switch and the two doors. This script goes on the switch.

Note: You are totally mis-using the 'elseif' command.

scn ContDoorScriptfloat timershort myStateBegin Onactivate	if myState > 0		return	endif	if Door1.GetOpenState == 1	;Door1 is open		set myState to 1		Door1.SetOpenState 0	;Close Door1		set timer to 10	else				;Door1 is closed so Door2 must be open		set myState to 2		Door2.SetOpenState 0	;Close Door2		set timer to 10	endifendBegin GameMode	if myState == 0		return	endif	if timer >= 0		set timer to timer - GetSecondsPassed		return	endif	if myState == 1		;Now that Door1 is closed open Door2		Door2.SetOpenState 1		set myState to 3		set timer to 5	elseif myState == 2		;Now that Door2 is closed open Door1		Door1.SetOpenState 1		set myState to 3		set timer to 5	elseif myState == 3		;Reset the switch		set myState to 0	endifend

User avatar
Gill Mackin
 
Posts: 3384
Joined: Sat Dec 16, 2006 9:58 pm

Post » Wed Jan 12, 2011 5:34 pm

Oh crap your right. Sorry I meant 'Else' not 'ElseIf'. I guess that is simpler too >.>
User avatar
carla
 
Posts: 3345
Joined: Wed Aug 23, 2006 8:36 am

Post » Wed Jan 12, 2011 11:21 am

@Gunmaster95 - For the 'elseif', I meant the OP, not you. :)

Another thing, if you remove the 'name' from the airlock doors, then the player cannot activate them. Otherwise you will need to put a 'null' script on the doors so the player can't just activate them.

begin OnActivatereturnend

User avatar
Dawn Porter
 
Posts: 3449
Joined: Sun Jun 18, 2006 11:17 am

Post » Wed Jan 12, 2011 7:19 pm

You can probably tell I know nothing about scripting, never done it before so my attempt was probably full of errors and inefficiencies. I'm just glad people who do know are willing to share information and help those less knowledgeable, so thanks to all for replying.

What I've done is use DoorRemoteOpenSCRIPT on the two doors, which tell the player they're activated elsewhere (at the switch). That works, and the script you wrote WillieSea is almost working on the switch but for a small problem I'm having when I first load the dungeon. When I enter for the first time, Door2 (which should be closed) appears open so I can walk through the airlock without having to use the switch at all.

Moreover, two or three seconds after loading the cell for the first time Door2 will spring to a closed state (without playing the closing animation) and then open again. I'm unable to use the switch during the first 13 seconds or so, and wonder if the script is running before I activate the switch? When I do activate for the first time, Door1 closes and Door2 holds in an open state for 10 seconds. When I activate a second time and additional times after that the script works perfectly. If I can fix Door2 so it's closed when I load the dungeon, I think I'll be sorted. But how would I do that?

Both doors are persistent references with unique names and IDs, and Door2 definitely isn't flagged as 'open by default'. There's no duplicate doors in the same space either.
User avatar
Petr Jordy Zugar
 
Posts: 3497
Joined: Tue Jul 03, 2007 10:10 pm

Post » Wed Jan 12, 2011 9:37 am

You are probably using a 'dirty' save game. The state of doors is 'saved' in your save game, making the mod 'dirty'.
You need to use a saved game where your mod was NEVER active when you saved the game.
User avatar
elliot mudd
 
Posts: 3426
Joined: Wed May 09, 2007 8:56 am

Post » Wed Jan 12, 2011 8:53 am

You are probably using a 'dirty' save game. The state of doors is 'saved' in your save game, making the mod 'dirty'.
You need to use a saved game where your mod was NEVER active when you saved the game.


Ah, sorted now. I was loading my 2nd to last save (before I'd found the dungeon) but the mod had been active longer than that. I managed to go back further and get a save before the mod became live, and the doors work perfect! Thanks again for the help. :)
User avatar
Loane
 
Posts: 3411
Joined: Wed Apr 04, 2007 6:35 am

Post » Wed Jan 12, 2011 6:38 pm

the best save I found for testing you mods is one right out of vault 101, then run a batch script to boost the character if needed when using it.

I got a couple batch scripts that run up to 10, 20 and 30 on levels. just level up, and add a few gear items.
User avatar
Juan Suarez
 
Posts: 3395
Joined: Sun Nov 25, 2007 4:09 am

Post » Wed Jan 12, 2011 3:28 pm

I've definitely learnt my lesson there,


I've added in a couple of particle objects I'd like to enable 2 seconds after Door 1 closes and disable 2 seconds before Door 2 opens, and vice versa of course. But I can't seem to make the script do that. I'll activate the switch and the particles turn on as door 1 is closing and turn off just before Door 2 starts to open.

scn WDContDoorSCRIPT ;Credit to WillieSeafloat timershort myStateBegin OnActivate	if myState > 0		return	endif	if DeconDoor1.GetOpenState == 1		set myState to 1          set timer to 2 ;NEW          Spray1.enable ;NEW          Spray2.enable ;NEW		DeconDoor1.SetOpenState 0		set timer to 10	else		set myState to 2           set timer to 2 ;NEW          Spray1.enable ;NEW          Spray2.enable ;NEW		DeconDoor2.SetOpenState 0		set timer to 10	endifendBegin GameMode	if myState == 0		return	endif	if timer >= 0		set timer to timer - GetSecondsPassed		return	endif	if myState == 1          set timer to 2 ;NEW          Spray1.disable ;NEW          Spray2.disable ;NEW		DeconDoor2.SetOpenState 1		set myState to 3          set timer to 5	elseif myState == 2           set timer to 2 ;NEW          Spray1.disable ;NEW          Spray2.disable ;NEW		DeconDoor1.SetOpenState 1		set myState to 3          set timer to 5	elseif myState == 3		;Reset the switch		set myState to 0	endifend


Sorry it's so long but I wanted to show you what I've added and where. As before, my knowledge of scripting is NIL but I like to make an effort and at least try to understand it before I ask for help. :)
User avatar
teeny
 
Posts: 3423
Joined: Sun Feb 25, 2007 1:51 am

Post » Wed Jan 12, 2011 5:37 pm

Its because you are telling it to do that.
For example:
	if myState == 1		set timer to 2 ;NEW		Spray1.disable ;NEW		Spray2.disable ;NEW		DeconDoor2.SetOpenState 1		set myState to 3          set timer to 5

Here you set timer to 2, then disable the spray jets, then you set door2 to open, and then set the state to 3.
What will then happen is after 2 seconds pass, the code inside myState == 3 will be performed.


If you want more conditions, then you have to create new 'myState' sections of code to handle each new section. You may notice I increment myState by 1 after each timer has run out. And each myState section performs the 'next' thing I want to happen.
User avatar
Rich O'Brien
 
Posts: 3381
Joined: Thu Jun 14, 2007 3:53 am

Post » Wed Jan 12, 2011 6:19 pm

Fixed! Thanks again!

My script now follows this logic.

OnActivate
if condition == 1
setmyState to 1
do stuff
set timer
set myState to 3
else
setmyState to 2
do stuff
set timer
setmyState to 4
end

OnGameMode
if myState == 0 (return)
define the timer
if myState == 1 (open door, proceed to myState 7)
if myState == 2 (open door, proceed to myState 7)
if myState == 3 (enable effects, set timer, proceed to myState 5)
if myState == 4 (enable effects, set timer, proceed to myState 6)
if myState == 5 (disable effects, set timer, proceed to myState 1)
if myState == 6 (disable effects, set Timer, proceed to myState 2)
if myState == 7 (set timer, reset switch)
end


So basically Door1 uses myStates 1,3,5 and 7 while Door 2 uses 2,4,6 and 7. It may not be the most efficient way, but it works.
User avatar
Katie Samuel
 
Posts: 3384
Joined: Tue Oct 10, 2006 5:20 am


Return to Fallout 3