35 lines
863 B
Plaintext
35 lines
863 B
Plaintext
|
//Lock a door with a lever - main script
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
string sTag = GetTag(OBJECT_SELF);
|
||
|
sTag = GetStringLeft(sTag, GetStringLength(sTag) - 2) + "dr";
|
||
|
object oDoor = GetNearestObjectByTag(sTag);
|
||
|
|
||
|
|
||
|
if ( GetLocalInt( OBJECT_SELF, "m_bActivated" ) == TRUE )
|
||
|
{
|
||
|
SetLocalInt( OBJECT_SELF, "m_bActivated", FALSE );
|
||
|
PlayAnimation( ANIMATION_PLACEABLE_DEACTIVATE );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
SetLocalInt( OBJECT_SELF, "m_bActivated", TRUE );
|
||
|
PlayAnimation( ANIMATION_PLACEABLE_ACTIVATE );
|
||
|
}
|
||
|
|
||
|
|
||
|
if (GetLocked(oDoor) == TRUE)
|
||
|
{
|
||
|
SetLocked(oDoor, FALSE);
|
||
|
SpeakString("The door has been unlocked.");
|
||
|
DelayCommand(1.0, ActionOpenDoor (oDoor));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
ActionCloseDoor(oDoor);
|
||
|
DelayCommand(2.5, SetLocked(oDoor, TRUE));
|
||
|
DelayCommand(3.0, ActionSpeakString("The door is now locked"));
|
||
|
}
|
||
|
}
|