Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

sliding door help please?

Dawn Ireton
Registered User
Join date: 28 Aug 2007
Posts: 30
09-06-2008 08:45
Hello all, I need a bit of help. I have been searching now for a while for a sliding door script that can both be linked and locked with the ability to add other users to the "allow list". I have come up empty handed thus far. I realize that there are scripts that do some of the things I need, and can most likely be modified to do it all, but I can not script worth a hoot. I really need this script for a build I am working on, so if anyone can offer some assistance I would be very grateful. TY in advance :)
~Dawn
Virtual Foxtrot
Registered User
Join date: 3 Sep 2008
Posts: 5
Hope this helps
09-06-2008 08:49
I found this a few days back on slexchange. I have not looked at it yet but might help you in your hunt. Free open source

http://uncensored.slexchange.com/modules.php?name=Marketplace&file=item&ItemID=871999
Dawn Ireton
Registered User
Join date: 28 Aug 2007
Posts: 30
09-06-2008 09:12
TY Virtual, I picked up a copy from SLEX, and it does have everything I want, plus extra, but for some reason it moves on the diagonal instead of on one of the axis. I tried to mod the script, but I just couldn't make head or tails of it really. Any other ideas for me? Ty again for your help :)
Virtual Foxtrot
Registered User
Join date: 3 Sep 2008
Posts: 5
hmmmm
09-06-2008 09:16
I will look at it and see what I can do. hehe
Virtual Foxtrot
Registered User
Join date: 3 Sep 2008
Posts: 5
lol
09-06-2008 09:20
Ok when you rez it fix it so that xyz is not in a angle then reset the script should move side to side then.
Dawn Ireton
Registered User
Join date: 28 Aug 2007
Posts: 30
09-06-2008 09:38
Ty Virtual, that did it. Any idea now how I can make the motion smoother instead of moving in three jerky steps?
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-06-2008 12:37
From: Dawn Ireton
Ty Virtual, that did it. Any idea now how I can make the motion smoother instead of moving in three jerky steps?


i'll check it out when i get home tonight, i'm guessing since it already has 3 steps, you can probably add more steps
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
09-06-2008 14:36
From: Dawn Ireton
Hello all, I need a bit of help. I have been searching now for a while for a sliding door script that can both be linked and locked with the ability to add other users to the "allow list". I have come up empty handed thus far. I realize that there are scripts that do some of the things I need, and can most likely be modified to do it all, but I can not script worth a hoot. I really need this script for a build I am working on, so if anyone can offer some assistance I would be very grateful. TY in advance :)
~Dawn


Hi Dawn , this should do the job, based on scripts found on the forum ,this door can be linked , moved , rotated and still works .Add a notecard "whitelist" to the contents for other users.
CODE

//Sliding Door v4
//Works when linked
//by Kayla Stonecutter
//-- tweaked heavily by Void Singer Mar 10, 2008

//How far in meters to travel in each direction. Two or all three can be used for angled movement
//NOTE: when linked, this is relative to the root prim
float y = 1.0;
float x = -0.0;
float z = 0.0;

vector Offset;
///////////////////////////////
list allowedNames;
string notecard = "whitelist";
integer lineCounter;
key dataRequestID;

integer AllowEntry(key id)
{
string name = llToLower(llKey2Name(id));
integer iIndex = llListFindList(allowedNames, [ name ]);
// Always allow the owner
if(llGetOwner() == id) iIndex = 9999;

integer result = FALSE;
if(iIndex >= 0) result = TRUE;
return result;
}
Changed(integer change)
{
// Test for a changed inventory
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
else if (change & CHANGED_OWNER)
{
llResetScript();
}
}

default
{
state_entry()
{
state ReadConfig;
}

on_rez (integer num) { llResetScript(); }

changed(integer change) { Changed(change) ;
llSetRot( llGetLocalRot()); }
}
//------------------------------------------------------------
state Running
{
state_entry()
{
Offset = <x,y,z>;
}

touch_start( integer vIntNull )
{
key id = llDetectedKey(0);
if(AllowEntry(id))
{
llSetPos( llGetLocalPos() + Offset );
//-- reverse offset so next time it goes the opposite direction
Offset = -Offset;
}
else
{
llWhisper(0,"Sorry but only allowed people can open this door");
}
}


changed(integer change) { Changed(change) ; }


}

//--------------------------------------------------------------------------------
state ReadConfig
{
state_entry()
{
lineCounter = 0;
allowedNames = []; // List of Allowed Users
integer itemtype = llGetInventoryType(notecard);
if(INVENTORY_NOTECARD == itemtype)
{
dataRequestID = llGetNotecardLine(notecard, lineCounter);
llSetTimerEvent(10);
}


}

dataserver( key query_id, string data ) // read from the notecard
{
if(query_id == dataRequestID)
{
if (data != EOF)
{
if(llGetSubString(data, 0,0) != ";")
{
allowedNames += llToLower(data);
llOwnerSay("Allowing "+data);
}
lineCounter++;
dataRequestID = llGetNotecardLine( notecard, lineCounter );
}
else
{
llSetTimerEvent(0);
state Running;
}
}
}

timer()
{
llOwnerSay("ERROR - Dataserver time out! aborting");
llSetTimerEvent(0);
state Running;
}

on_rez(integer num) { llResetScript(); }

changed(integer change) { Changed(change) ; }

}
CODE
canis Oh
Registered User
Join date: 30 Mar 2007
Posts: 33
buy modifiable doors instead?
09-06-2008 17:35
Dawn get over to "OLB Showcase", we have full perm double and single doors. Sorry script is not modifiable but everything else is. Try the demonstration on the panel provided. I'll help if you have questions.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
09-06-2008 18:26
Here's my stab at it, based on Lillani Lowell's method at /54/c1/102699/1.html#post1141537
The owner, who can always open the doors, adds people to the access list by saying their name on the appropriate channel. Don't make one of the doors the root prim, please. The control script can be anywhere else in the linkset; if it's in the root prim then touching the structure anywhere will open and close the doors, which may or may not be what you want to happen.
Control script:
CODE
integer toggle = 1;
list authorized;
integer index;
integer myChannel = 245; //change this
float distance = 0.5; // distance for each door to slide open
float open_time = 5; // set to 0 if you don't want them to close automatically after this number of seconds

integer HaveAccess(string name)
{
for(index=0;index<llGetListLength(authorized);index++)
{
if (llList2String(authorized,index)==name)
{
return TRUE;
}
}
return FALSE;
}

default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llListen(myChannel,"",NULL_KEY,"");


}
listen( integer channel, string name, key id, string message )
{

if (id==llGetOwner())
{
authorized += message;
llOwnerSay ( message + " added");

}
}

touch_start(integer total_number)
{
string name = llDetectedName(0);
string owner = llKey2Name(llGetOwner());

if (HaveAccess(name)==TRUE || name == owner)

{ toggle *= -1;
if (toggle <0)
{
llMessageLinked( LINK_SET, 1, (string)distance, NULL_KEY );
llSetTimerEvent(open_time);
}
else if (toggle > 0)
{
llMessageLinked( LINK_SET, 2, (string)distance, NULL_KEY);
}
}
}
timer()
{
if (toggle > 0) // someone's closed us already
{
llSetTimerEvent(0);
}
else if (toggle < 0)
{
toggle *= -1;
llMessageLinked( LINK_SET, 2, (string)distance, NULL_KEY);
}

}
}
and put one of the following in each of the sliding doors (depending on which way it slides to open). This one moves forwards along the Y axis to open:
CODE
vector door_move;

default
{

link_message( integer sender_num, integer num, string message, key id )
{
float distance = (float) message;
if( num == 1)
{

door_move = llGetLocalPos();

door_move.y += distance;

llSetPos( door_move );

}

if( num == 2)
{

door_move = llGetLocalPos();

door_move.y -= distance;

llSetPos( door_move );

}

}

}
and this one moves in the opposite direction:
CODE
vector door_move;

default
{

link_message( integer sender_num, integer num, string message, key id )
{
float distance = (float) message;

if( num == 1 )
{

door_move = llGetLocalPos();

door_move.y -= distance;

llSetPos( door_move );

}

if( num == 2 )
{

door_move = llGetLocalPos();

door_move.y += distance;

llSetPos( door_move );

}

}

}
Dawn Ireton
Registered User
Join date: 28 Aug 2007
Posts: 30
09-07-2008 12:04
Thanks so much to both Billy and Innula for these scripts. I have not had a chance to try Billy's out yet because of the troubles SL was having last night, but I am on my way in world now to see how it does. Innula's script works perfectly and even has an added bonus of both doors opening and closing together.
Ty canis for the heads up on OLB, but for this project I really do need a modifiable script. I will keep them in mind for my next build however.
Ty so much to everyone who has answered this post and provided so much help with this! :)
~Dawn