Sliding Door Script SL

31 May

integer pitch = 50; //Steps for the door to take to open and close. More Steps will make the door open and close more slowly.
float TimeInterval = 6.0; //Seconds to keep the door open.
integer TouchFlag;
integer Holding;
integer SecureFlag;

Open()
{
TouchFlag = TRUE;
llTriggerSound(“DoorSound”, 1.0);
integer i;
for(i = 0; i < pitch + .5; i++)
{
llSetPrimitiveParams([PRIM_TYPE, 0, 0, ,
0.949000, , ,
]);
}
llSetTimerEvent(TimeInterval);
}

Close()
{
llSetTimerEvent(0);
TouchFlag = FALSE;
llTriggerSound(“DoorSound”, 1.0);
integer i;
for(i = pitch – 1; i >= 0 ; i–)
{
llSetPrimitiveParams([PRIM_TYPE, 0, 0, ,
0.949000, , ,
]);
}
}

TouchOpen()
{
if(TouchFlag == FALSE)
{
Open();
}
else
{
Close();
}
}

CollideOpen()
{
if(TouchFlag == FALSE)
{
Open();
}
else
{
llSetTimerEvent(TimeInterval);
}
}

Init()
{

}

default
{
state_entry()
{
Init();
}
changed(integer change)
{
if(change & CHANGED_OWNER)
{
llResetScript();
}
}
touch(integer total_number)
{
if(llDetectedKey(0) == llGetOwner())
{
Holding++;
if(Holding == 50)
{
if(SecureFlag == FALSE)
{
llOwnerSay(“Door Locked”);
SecureFlag = TRUE;
}
else
{
llOwnerSay(“Door Unlocked”);
SecureFlag = FALSE;
}
}
}
}
touch_end(integer total_number)
{
Holding = 0;
if(SecureFlag == FALSE)
{
TouchOpen();
}
else
{
if(llDetectedKey(0) == llGetOwner())
{
TouchOpen();
}
else
{
llWhisper(0, “Sorry, this door is locked.”);
}
}
}
collision_start(integer num_detected)
{
if(SecureFlag == FALSE)
{
CollideOpen();
}
else
{
if(llDetectedKey(0) == llGetOwner())
{
CollideOpen();
}
else
{
llWhisper(0, “Sorry, this door is locked.”);
llSleep(5.0);
}
}
}
timer()
{
Close();
}
}

This also has a lock feature but I am not using this in the game, the doors open by clicking or causing contact, they play a sound that sounds like moving rocks… Its actually a bicycle on gravel from the bbc sound collection.

Leave a comment

Design a site like this with WordPress.com
Get started