Jump to content

[Scripting] Auto Door Close Script


kamenai

Recommended Posts

So I'm working on my exterior worldspace cafe mod, and the final touch is to add a script to the door to make the door close a few seconds after being opened. I've made an exterior worldspace player home and found a script posted here on the forums and it worked perfectly. So I used it for this mod and it doesn't work. I activate the door in game, wait, and the door just stays open. I originally wanted it to just stay open for 3 seconds. I waited way longer than that. Then I waited a few minutes, still nothing. I've found and used several different scripts posted by other users that do the same thing, I can't get any of them to work. For reference, scripts by: djjohnjarvis, sLoPpYdOtBiGhOlE, Ghaunadaur have all failed to work. I'm at a loss because I've done this before with ease and now it doesn't work. I don't know how to script, so maybe there's something I have missed.

 

 

Link to comment
Share on other sites

All of the code has been commented out.
Remove the curly braces at "{Scriptname" and "EndEvent}", then remove the second instance of "Scriptname CloseDoor extends ObjectReference" entirely.

After that, something needs to tell the setopen function exactly what it's closing. "Self" should work, methinks. So, in the end, your code would look like:

Scriptname CloseDoor extends ObjectReference

Event OnOpen(ObjectReference akActionRef)

Utility.wait(3)
Self.SetOpen(False)


EndEvent

Alternatively, you can have the door check if it's actually open.

Event OnActivate(ObjectReference akActionRef)

int openState = Self.GetOpenState()

If (openState == 1 || openState == 2) ; Open or opening
  Utility.wait(3)
  Self.SetOpen(False)


EndIf

EndEvent

Edited by Undivide
Link to comment
Share on other sites

  • Recently Browsing   0 members

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