How to make a door auto close after a deley?

Post » Wed Jun 20, 2012 9:17 pm

hi im trying to make a wolfdoor. close after a deley.

Here's what happens.

There's wolfdoor in front of a hole, im trying to make it so that when i press a button
it opens the door and the enemy comes out, after 5 seconds of him exiting the item
i want the doors to auto close behinde him with out pushing the button again or any
other buttons.

Here's what i have tried and it works. but not well.

I have 2 doors inside each other one, one open by defult. the other closed.
i have set one door with a activated parent with a deley of 5 seconds.
so one will open the other with the deley will close in 5 seconds looking
like there one door and it close's itself but i will have alot of doors,
maybe 100+ and im trying to save making more doors.

any idea how i can doi this with the one door, im thinking maybe a script
but i cant script can some one help me?

Oh and this has to be repatable so i can have the same doors do the same thing
with other buttons. so the other buttons work in the same way as the first and does'nt
change it. Hope some one can help thanks !please try and keep it simple.
User avatar
Bones47
 
Posts: 3399
Joined: Fri Nov 09, 2007 11:15 pm

Post » Wed Jun 20, 2012 9:42 pm

In the OnActivate() event for the door, have it RegisterForSingleUpdate(5.0) then in the OnUpdate() event, call Close()
User avatar
Betsy Humpledink
 
Posts: 3443
Joined: Wed Jun 28, 2006 11:56 am

Post » Wed Jun 20, 2012 11:13 pm

Im sorry i don't understand? the door doesnt have any scipts at all.
I take it this is part of a script sorry im lost :S
User avatar
Victoria Bartel
 
Posts: 3325
Joined: Tue Apr 10, 2007 10:20 am

Post » Wed Jun 20, 2012 9:57 pm

Make a copy of the door type you want to do. Call it "AutomaticallyClosingDoor" or something, and put this script on it:

Event OnActivate()  If !IsLocked()    SetOpen(True)    RegisterForSingleUpdate(5.0)  EndifEndEventEvent OnUpdate()    SetOpen(False)EndEvent
User avatar
Benito Martinez
 
Posts: 3470
Joined: Thu Aug 30, 2007 6:33 am

Post » Wed Jun 20, 2012 2:11 pm

I've actually got a few in my location mod; as Redwood Elf says, I created new forms of the doors and added this script:
Scriptname Z0AutoShutDoorSCR extends ObjectReference  {Auto shuts a door after n seconds}Int Property numSecs = 3 Auto  Event OnOpen(ObjectReference akActionRef)    If (akActionRef == Game.GetPlayer())        Utility.Wait(numSecs)        Self.SetOpen(False)    EndIfEndEvent
The Int property numSecs is a property I added to the script of the object itself - this can be adjusted to whatever is required.
User avatar
Brandi Norton
 
Posts: 3334
Joined: Fri Feb 09, 2007 9:24 pm

Post » Thu Jun 21, 2012 12:25 am

"Self" is redundant in that context. You only need to use self if you need to pass it to a function.
User avatar
Josee Leach
 
Posts: 3371
Joined: Tue Dec 26, 2006 10:50 pm

Post » Wed Jun 20, 2012 12:17 pm

Redwood Elf, when you say (Make a copy of the door type you want to do)
what do you mean? do you mean make another door like copy and paste/duplicate?

And i tried your scipt redwood Elf but it didnt save i know im missing something realy silly here?

Other than that thats Brillant! just what i needed. thanks!
User avatar
Lucky Girl
 
Posts: 3486
Joined: Wed Jun 06, 2007 4:14 pm

Post » Wed Jun 20, 2012 7:52 pm

My Bad...forgot the parameter on OnActivate()

The easiest way to attach a script to a door would be to make a little quest just to control the doors.

Make a new quest, click on "Start Game Enabled" and click "OK", then go back in the quest and make an alias for each door you want this behavior on, picking each door in the render window. Then click on "Add" in the scripts part of the quest alias window, pick "New Script", and in the script source, add the two events above. Once you've made one of these aliases, Rightclick on the first one and duplicate it until you have enough of them for all the doors and then select the doors in the render window for each alias.

Scriptname AutoCloseAfterDelay extends ObjectReferenceFloat property DelayTime=5.0 AutoEvent OnActivate(ObjectReference Who)  If !IsLocked()    SetOpen(True)    RegisterForSingleUpdate(DelayTime)  EndifEndEventEvent OnUpdate()    SetOpen(False)EndEvent
User avatar
Marie
 
Posts: 3405
Joined: Thu Jun 29, 2006 12:05 am


Return to V - Skyrim