32 lines
841 B
Plaintext
Raw Permalink Normal View History

/*
This script is used on the OnOpen event of any door.
if the door tag is Door_20, then the door will close
after 20 seconds. If the tag is DoorToBar_30, it will
close after 30 seconds. If there is no time specified
at the end of the door tag, it uses a default of 10 seconds.
I also added a minimum time to close which is currently set
at 4 seconds.
*/
void main()
{
float fDelay = 10.0;
float fMinimumDelay = 4.0;
string sDoorTag = GetTag(OBJECT_SELF);
int iDelimPos = FindSubString(sDoorTag, "_");
int iBaseLen = GetStringLength(sDoorTag);
if (iDelimPos != -1)
{
fDelay = StringToFloat(GetStringRight(sDoorTag, iBaseLen - iDelimPos - 1));
}
if (fDelay < fMinimumDelay)
{
fDelay = fMinimumDelay;
}
DelayCommand (fDelay, ActionCloseDoor(OBJECT_SELF) ); //Shuts door
}