Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

secret room lock help

Voodo Capalini
Registered User
Join date: 17 Apr 2007
Posts: 3
04-23-2008 09:01
Hi i'm putting a secret room under a rug that slide's to reveal a hole to the room.

I found the script on the forum, for a sliding door and added it to the rug but i only want it accessable to myself, so what would i add to the script to make the rug slide only when i toutch it.

//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
//Positive = move north, negative = move south
float NorthSouth = 3.0;
//Positive = move east, negative = move west
float EastWest = -0.0;
//Positive = move up, negative = move down
float UpDown = 0.0;

//The amount in seconds to stay open, set to 0 to not autoclose
//-- delete next line if not using autoclose
float Timer = 0.0;

//-- begin sound section: delete to 'end sound section' if not using sounds

//Sound to play on open, either a UUID or a name in the door contents
// in quotation marks. if a name, it must be exact.
string OpenSound = "";

//Volume to play open sound, 0.0 is same as no sound, 1.0 is max
//-- setting this to 0.0 turns off open sounds
float OpenVol = 0.0;

//Sound to play on close, either a UUID or a name in the door contents
// in quotation marks. if a name, it must be exact.
string CloseSound = "";

//Volume to play close sound, 0.0 is same as no sound, 1.0 is max
//-- setting this to 0.0 turns off close sounds
float CloseVol = 0.0;

//-- end sound section

//misc variables
vector Offset;
integer Open;

//-- begin sound trigger: delete to 'end sound trigger' if not using sounds

//-- included to trap errors triggering sounds which delay the script firing
fTriggerSound(string sound, float volume)
//Written by Strife Onizuka
//-- tweaked by Void Singer
{
if (volume){
//-- makes sure sound is valid before playing
if ((key)sound);
else if (INVENTORY_SOUND == llGetInventoryType( sound ) );
else{
return;
}
llTriggerSound(sound, volume);
}
}
//-- end sound trigger

fTriggerSlide(){
//-- begin sound trip: delete to 'end sound trip' if not using sounds
if (Open)
{
fTriggerSound( CloseSound, CloseVol );
}else
{
fTriggerSound( OpenSound, OpenVol );
}
//-- end sound trip

llSetPos( llGetLocalPos() + Offset );
//-- reverse offset so next time it goes the opposite direction
Offset = -Offset;
//-- reverse open state tracking
Open = !Open;

//-- delete next line if not using autoclose
llSetTimerEvent( Timer * Open); //-- if closed timer is turned off
}

default
{
state_entry()
{
Offset = <EastWest, NorthSouth, UpDown>;
}

touch_start( integer vIntNull )
{
//-- safer to ignore simultaneaous touches in doors,
//-- so we dont bother processing more than the first
fTriggerSlide();
}

//-- removed on rez reset because it could reverse the open logic and break the offset.

//-- begin timer: delete to 'end timer' end if not using autoclose
timer()
{
//-- test if it's open so queued timer events don't accidently fire movement code
if (Open)
{
fTriggerSlide();
}
}
//-- end timer
}
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
04-23-2008 09:20
There is a small section of code that you can add to to make it only work for you. This is nearing the end of the entire script. The if statement I added in will make it open only for you, and won't give a warning or anything else to anyone else who tries to open it. Basically what it's doing is checking the key of the avatar and see if it matches your key. If so, it triggers the fTriggerSlide(); function defined above.

This is not the entire script, it's just the altered bit.

CODE

touch_start( integer vIntNull )
{
//-- safer to ignore simultaneaous touches in doors,
//-- so we dont bother processing more than the first
if(llDetectedKey(0) == llGetOwner())
{
fTriggerSlide();
}
}
_____________________
Tutorials for Sculpties using Blender!
Http://www.youtube.com/user/BlenderSL
Voodo Capalini
Registered User
Join date: 17 Apr 2007
Posts: 3
04-23-2008 09:27
Thank you so much i will try it :)

[edit]

that worked a treat :) thank you for your time, much appreciated :)
Renee Roundfield
Registered User
Join date: 10 Mar 2006
Posts: 278
04-23-2008 09:34
You just need to wrap this around the command in the touch_start event:
if ( llGetOwner() == llDetectKey(0))
{
(your trigger command here)
}
Keira Wells
Blender Sculptor
Join date: 16 Mar 2008
Posts: 2,371
04-23-2008 09:43
From: Voodo Capalini
Thank you so much i will try it :)

[edit]

that worked a treat :) thank you for your time, much appreciated :)

yay ^_^ My pleasure
_____________________
Tutorials for Sculpties using Blender!
Http://www.youtube.com/user/BlenderSL
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-23-2008 11:37
It's probably a very minor issue, but if you want to keep people from being able to prevent your touches by themselves touching repeatedly (sort of a minor denial of service attack), you could also do:

CODE

touch_start(integer nDetected)
{
key owner = llGetOwner();
integer i;
for (i = 0; i < nDetected; ++i)
{
if (llDetectedKey(i) == owner)
{
fTriggerSlide();
return;
}
}
}