Door Auto Close Code

The Door Auto Close project page has a zip file, the contents of which does not contain any code. This is because the original vault page didn’t have anything to download. Instead it had a code window. As it is such a simple project I am posting that code here instead of providing a link to the relevant rolovault page. Here is the ‘missing’ code.

Filename:           door_auto_close
System:             miscellaneous
Author:             WizardStorm Think Group (
Date Created:       Oct 7th, 2006.
Automatically shuts oDoor1 after an set amount of time. If oDoor1 is
connected to oDoor2 via a transition, it will close oDoor2 at the same time.
By default, doors close after 30 seconds, however you can override this by
setting a local float variable on the door called AUTO_SHUT_DELAY.
If AUTO_SHUT_DELAY equals -1.0, the door will never auto close.
void main()
	object 	oDoor1 			= OBJECT_SELF;
	object 	oDoor2 			= GetTransitionTarget(oDoor1);
	float	fShutDefault	= 30.0;
	float  	fShutDelay 		= GetLocalFloat(oDoor1, "AUTO_SHUT_DELAY");
	if(fShutDelay == -1.0)
	else if(fShutDelay == 0.0)
		fShutDelay = fShutDefault;
	AssignCommand(oDoor1, DelayCommand(fShutDelay, ActionCloseDoor(oDoor1)));
	AssignCommand(oDoor2, DelayCommand(fShutDelay, ActionCloseDoor(oDoor2)));

Have fun.



I don’t think you want this to run during combat.

do a sightcheck for any PC within <sightdistance> first … (if true, do recurse)

because spooky doors closing is spooky.

1 Like