Door that closes after you move away from it

Post » Tue Nov 20, 2012 2:05 am

I'm using a modified portcullis changed to look like a section of wall.
It has the Default2StateActivator script.

I put a trigger box around it and will set it as the Activate Parent of the portcullis.
I'm thinking I could use the DefaultActivateSelf script from the Warehouse Ambushes with OnTriggerEnter changed to OnTriggerLeave and most of the part about followers and activation by others removed.
But how will I tell it to only activate if the portcullis is already open?

If I cut away what I think isn't needed it looks like this:

ScriptName CloseDoor extends objectReference
{script that simply activates itself when player leaves trigger}

import game
import debug

bool property doOnce = FALSE auto
{Fire only once? Default: FALSE}
bool property disableWhenDone = FALSE auto
{Disable after activating? Default: FALSE}
bool property playerOnly = TRUE auto
{Only Player Triggers? Default: TRUE}

;************************************
auto State waiting

Event onTriggerLeave(objectReference triggerRef)
Actor actorRef = triggerRef as Actor
if(actorRef == game.getPlayer()); check whether the player is activating

if(PORTCULLIS IS OPEN)

if doOnce == TRUE
gotoState("allDone")
endif

if disableWhenDone
Self.Disable()
endIf

activate(self); pass self as the activating ref

endif
endif

endEvent

endState

;************************************
User avatar
CHANONE
 
Posts: 3377
Joined: Fri Mar 30, 2007 10:04 am

Post » Tue Nov 20, 2012 5:53 am

This will tell you what state the door is in.

http://www.creationkit.com/GetOpenState_-_ObjectReference


And its probably better to use this to open or close the door:

http://www.creationkit.com/SetOpen_-_ObjectReference
User avatar
Alan Whiston
 
Posts: 3358
Joined: Sun May 06, 2007 4:07 pm

Post » Mon Nov 19, 2012 10:40 pm

I tried your suggestion. The lines with semicolons failed to compile either singly or together. The "door" it's refering to isn't really a door but a section of wall that slides up. It's listed as an activator not a door. Does that make a difference?

Scriptname CloseDoorScript Extends ObjectReference

Activator Property MyDoor Auto
Actor Property PlayerREF Auto
Int Property OpenState Auto

Event OnTriggerLeave(ObjectReference akActionRef)

;OpenState = MyDoor.GetOpenState()

If akActionRef == PlayerREF
;If (OpenState == 1 || OpenState == 2)
;MyDoor.SetOpen(false)
;EndIf
EndIf
Debug.Messagebox("yipee")
EndEvent
User avatar
Guinevere Wood
 
Posts: 3368
Joined: Mon Dec 04, 2006 3:06 pm

Post » Tue Nov 20, 2012 12:14 am

Only a 'door' object can use SetOpen and OpenState. Since you are using an 'activator' object, you cannot use these door commands.

So that means you have to remember what state the activator is in, using a variable. I would recommend this triggerzone is the only way to open it as well.
So, open on enter and close on leave.
User avatar
Anthony Diaz
 
Posts: 3474
Joined: Thu Aug 09, 2007 11:24 pm

Post » Mon Nov 19, 2012 11:11 pm

"So that means you have to remember what state the activator is in, using a variable. I would recommend this triggerzone is the only way to open it as well.
So, open on enter and close on leave.
"

+1 - There are several Dwemer traps that use this method (eg spinning blades) that can be found in the 'warehouse traps' if you need a closer look.
User avatar
Verity Hurding
 
Posts: 3455
Joined: Sat Jul 22, 2006 1:29 pm

Post » Tue Nov 20, 2012 7:18 am

Having the triggerbox only to open or close it wouldn't work. I was trying to get a secret door that you open manually with a semi- hidden pull chain but that closed automatically when you moved away from it.
Second choice would be having the portcullis always start closed when you entered the cell somehow.
I was looking over the Default2StateActivator script on the portcullis but I really don't what all the Events and Functions mean. The script takes 3 pages
User avatar
WTW
 
Posts: 3313
Joined: Wed May 30, 2007 7:48 pm

Post » Mon Nov 19, 2012 8:45 pm

Solved it finally.
I added these lines to the Default2stateactivator script.

objectreference property mypullchain1 auto
objectreference property mypullchain2 auto


auto STATE waiting ; waiting to be activated
EVENT onActivate (objectReference triggerRef)
if (isOpen || (triggerRef == mypullchain1) || (triggerRef == mypullchain2))
; Debug.Trace("d2SA RESETS: " + Self + " " + isOpen)
; switch open state when activated
SetOpen(!isOpen)
if (doOnce)
gotostate("done")
endif
endif
endEVENT
endState
User avatar
Kate Schofield
 
Posts: 3556
Joined: Mon Sep 18, 2006 11:58 am


Return to V - Skyrim