Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Class #5 - Auto Doors


WillieSea
 Share

Recommended Posts

Automatic doors

So, you want to make an interior animated door automatically close?

Or you want to make make a door lock itself after being used?

Its not too difficult, but it can be tricky getting it to work the way you want it to.

XD Smarty Says: You may notice that the commands in these scripts do not actually 'reference' an object. The reason for this is you will place these scripts on the door itself, so the reference will be taken from the object it is on.

1) Automatic Closing interior door

scriptname MyDoorAutoCloseScript
float timer
short doWhat

Begin GameMode
if getopenstate != 1
if timer > 0
set timer to timer - getsecondspassed
else
if doWhat == 0
set timer to 5
set doWhat to 1
elseif doWhat == 1
setopenstate 0
set timer to 3
set doWhat to 2
elseif doWhat == 2
lock 100
set doWhat to 0
endif
endif
endif
End[/code] The variable 'doWhat' controls the door actions. a. When its equal to 0, and the door is now 'open', it will set a timer to a 5 second countdown and 'doWhat' is set to 1. b. When the countdown is done, the open state of the door is set to 0 which will close it. The timer is set to 2 seconds and 'doWhat' is set to 2. c. When that timer is up, the door is locked and the script is reset for the next activation by setting 'doWhat' back to 0. [color=#FFA500]2) Automatic locking static interior door[/color]
[code]scriptname myDoorLockScript
float timer
short doWhat

Begin GameMode
if ( getlocked )
else
if timer > 0
set timer to timer - getsecondspassed
else
if doWhat == 0
set timer to timer + 1
set doWhat to 1
return
elseif doWhat == 1
lock 100
set doWhat to 0
return
endif
endif
endif
End
This should lock the door 1 second after being unlocked. 3) Automatic Closing interior door with longer timer
scn MyDoorAutoClose1HrScript
short timerActive
float alarmTime
float alarmDay

Begin OnActivate
set timerActive to 1
set alarmTime to getCurrentTime + 1
set alarmDay to gameDaysPassed
if ( alarmTime >= 24 )
set alarmTime to alarmTime - 24
set alarmDay to alarmDay + 1
endif
activate
End

Begin GameMode
if timerActive == 1
if ( gameDaysPassed > alarmDay )
; The timer has expired
lock 100
set timerActive to 0
elseif ( gameDaysPassed == alarmDay )
if ( getCurrentTime >= alarmTime )
; The timer has expired
lock 100
set timerActive to 0
endif
endif
endif
End[/code]

This 'should' wait 1 hour before locking.

:lol: [color=#FF0000]Smarty Says:[/color] Check out the Lock page on the WIKI to know what value to set your locked door to.

As always, leave comments if you have questions or problems with the above information.

Link to comment
Share on other sites

the auto locking script for static doors I copied and pasted it in then clicked save and nothing happened at all

As in 'nothing happened', that is usually good for scripts.

If something happened, like an error message, than that would be bad.

If the script window will close with no message about asking you if you want to save the script first, then it saved just fine.

Link to comment
Share on other sites

  • 1 month later...

the self locking script doesn't seem to work right. it doesn't lock the door, rather it seems to close it. i want this to work because it'd make an awesome practice door for lock picking..

here's the script:

scn aaSDselflockingdoor50


float timer

short doWhat


begin GameMode

	if(getlocked)

	else

		if(timer>0)

			set timer to timer - getsecondspassed

		else

			if(doWhat==0)

				set timer to timer+1

				set doWhat to 1

				return

			elseif(doWhat==1)

				lock 50

				set doWhat to 0

				return

			endif

		endif

	endif

end

and we want this set as an object script correct? and we want to attach it to a door under the script heading... do we need to make it persistent? how do we use this exactly?

Edited by WillieSea
edited to add code tags
Link to comment
Share on other sites

Don't put the '+1' together like that. Use spaces like in my script example above.

timer to timer + 1

When you say 'timer+1' you are not adding 1 to the current contents of 'timer'. I would guess that nothing happens and it trys to lock the door before its closed, which will cause it to not lock.

It also depends on what door you are using, and if you had it default locked in the CS.

Link to comment
Share on other sites

so should the door be locked by default? it's how i set up mine. and i had wondered about the +1 thing since the script editor through a hissy when i didn't put a space before the getsecondspassed part... k gotta try again.

EDIT: nevermind the " + " spaces did the trick. that'll be handy for my mod. as a side note, can i attach this to a static door and still have it work?

Edited by spicydeath82
Link to comment
Share on other sites

Since this only locks things, you can put it on anything that is lockable, like doors or containers.

I had made a set of containers that were on a shelf, and each one had a different level of lock. So at the early levels, I could go after the easy ones. And then the harder ones at later levels. You could even add lockpicks to the container if you wanted.

Link to comment
Share on other sites

yeah, good idea. as part of the cs basics final i'm building a thieves retreat, and i wanted re-locking doors for the basement as a practice prop. i could add a separate jewelery box that re spawns lock picks, but only 5 at a time so as not to be too unbalanced. although at level 2 i already have 60+ of them from just looting stuff.... good tuts, i really enjoyed them.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...