So, i'm having some pretty frustrating issues here and i don't know where to start on this damned thing! Anyway. i have a frame and then two doors, one that is to slide left and the other to the right, into the wall. The script is in the frame of the door. Side note, for some reason, clicking on the frame will pop a debug saying that yes, its getting the click and opening and closing the door, but when i click on the doors themselves, it won't do that. i'm so confused. Would someone please help? (Heads up, i am, ah, rather new to scripting.) Thanks. Code below. /*
* Sliding double door! IT WORKS!
* By Lindsaykat (SL) / Katie Onyx (OpenSim private grid)
* With a lot of help from the SL forums (in no particular order):
* Qie Niangao, Rolig Loon, Profaitchikenz Haiku, Innula Zenovka
* Updated 20150730 1040 SLT
*/
//Variables
integer doorState = 0; //Indicates if door is opened or closed.
integer dLLink = -1; //Link number for left door.
integer dRLink = -1; //Link number for right door.
vector dLPos; //Left door original position.
vector dRPos; //Right door original position.
float dLSlide = -0.1; //Original left door slide amount.
float dRSlide = 0.1; //Original right door slide.
list paramsL; //List for left door parameters.
list paramsR; //List for right door parameters.
key owner = NULL_KEY;
float cT = 30.0; //Timer original time.
//Functions
init()
{
integer iiMax = llGetNumberOfPrims(); //Find the number of prims in the door.
integer ii; //To determine what the actual link numbers are....
for(ii = 1; ii <= iiMax; ++ii) //Find them using this!
{
string name = llGetLinkName(ii);
if(name == "L") //Feed the link number to dLLink
dLLink = ii;
else if(name == "R") //Or feed it to dRLink
dRLink = ii;
}
owner = llGetOwner();
}
open()
{
paramsL = llGetLinkPrimitiveParams(dLLink, [PRIM_POS_LOCAL]); //Grab original position, feed to left list.
dLPos = ((vector)llList2String(paramsL, 0)); //Also feed that vector to the original pos.
paramsR = llGetLinkPrimitiveParams(dRLink, [PRIM_POS_LOCAL]); //Feed original position to right list.
dRPos = ((vector)llList2String(paramsR, 0)); //Feed vector to position vector.
llSetLinkPrimitiveParamsFast(dLLink, [PRIM_POS_LOCAL, <dLPos.x, dLPos.y + dLSlide, dLPos.z>]); //Move dL along the Y axis .8 meters.
llSetLinkPrimitiveParamsFast(dRLink, [PRIM_POS_LOCAL, <dRPos.x, dRPos.y + dRSlide, dRPos.z>]); //Move the right door now, .8 meters, y axis.
doorState = 1; //Set the door state to 1.
//llWhisper(0, "Door Opened"); //Debugging.
llSetTimerEvent(30.0);
}
close()
{
llSetTimerEvent(0.0);
//Move doors back to original position.
llSetLinkPrimitiveParamsFast(dLLink, [PRIM_POS_LOCAL, dLPos]);
llSetLinkPrimitiveParamsFast(dRLink, [PRIM_POS_LOCAL, dRPos]);
doorState = 0; //Set door state to close.
//llWhisper(0, "Door Closed"); //Debugging.
}
//Main
default
{
state_entry()
{
if(owner == NULL_KEY)
init();
//Debugging.
//llSay(0, (string)dLLink);
//llSay(0, (string)dRLink);
llSetTimerEvent(0.0);
dLSlide = -0.65;
dRSlide = 0.69;
}
touch_start(integer num_detected) //When touched, open or close.
{
if(doorState == 0) //If door state is closed:
{
open();
}
else if(doorState == 1)
{
close();
}
else
{
//llWhisper(0, "Invalid Command");
}
}
timer()
{
close();
}
}