Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Sensor door with unknown avatar detection

Fixyou Kit
Registered User
Join date: 2 Jan 2007
Posts: 2
01-28-2007 03:48
CODE
// Fixyou Kit's sensor door script with unknown avatar detection.
// Door can be opened by up to 10 avatars, set up by name in the list.
// The door scans for any avatars witin a distance of "scandist" and reports any avatar that is not on the access list
// If known avatars get within a distance of "distdoor" to the door, it will open
//plz IM me if you have questions! Have fun!

//set names of avatars you want to allow access:
string access1 = "Fixyou Kit";
string access2 = " ";
string access3 = " ";
string access4 = " ";
string access5 = " ";
string access6 = " ";
string access7 = " ";
string access8 = " ";
string access9 = " ";
string access10 = " ";
integer distodoor = 3; // set distance (meters) between avatar and door to open
integer scandist = 500; //set scanning distance
string Ava_detected;
integer ava_known = 0;

default
{
state_entry()
{
llSensorRepeat("","",AGENT,scandist,TWO_PI,10.0);
llWhisper(0,"Scanner is active");
}

sensor(integer total_number)
{
integer x;
for (x = 0; x < total_number; x++)
{
vector pos = llGetPos();
string Ava_detected = llDetectedName(x);
float diff = llVecDist(pos,llDetectedPos(x));
integer dist = llRound(diff);
if(Ava_detected==access1 || Ava_detected==access2 || Ava_detected==access3 || Ava_detected==access4 || Ava_detected==access5 || Ava_detected==access6 || Ava_detected==access7 || Ava_detected==access8 || Ava_detected==access9 || Ava_detected==access10)
{
ava_known = 1;
}
if(ava_known == 0)
{
string detected = Ava_detected + " @ " + ((string)dist) + "m";
llWhisper(0,detected);
}
if(dist < distodoor)
{
if(ava_known == 1)
{
llWhisper(0,((string)dist)+" " + ((string)distodoor));
llPlaySound("startrekdoor", 0.5);
llSay(0, "Door open for "+(llDetectedName(0)));
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]);
llSleep (15);
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
dist = 100;
}
else
{
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]);
llSay(0, "Sorry "+(llDetectedName(0))+", can't let you enter, you are not on the access list");
}
}
}
}


no_sensor()
{
llWhisper(0,"No activity within " + ((string)scandist) + "m");
}

}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
01-28-2007 21:41
/15/06/163039/1.html
_____________________
i've got nothing. ;)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-29-2007 01:28
use a list rather than 10 distinct entries.
And using a sensor is overkill, I'd suggest you switch to using a volume detect prim.
Daisy Rimbaud
Registered User
Join date: 12 Oct 2006
Posts: 764
01-30-2007 03:00
From: Newgate Ludd

... using a sensor is overkill, I'd suggest you switch to using a volume detect prim.


What is that? I've never heard of it ...
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
01-30-2007 03:47
From: Daisy Rimbaud
What is that? I've never heard of it ...


Rather than using a sensor you can use a prim with llVolumeDetect(TRUE); in it.
This is passive, so less lag / sim resource useage.

Then when ever anyone walks into / through the prim you can use collision_start to tell your door that its been approached and who by.


CODE

integer channel = -9999;

GetParameters()
{
string str = llGetObjectDesc();
list ldata = llParseString2List(str, ["="], [""]);
string command = llList2String(ldata,0);
string value = llList2String(ldata,1);
if("Channel" == command)
{
channel = (integer)value;
}
}


default
{
state_entry()
{
GetParameters();
llVolumeDetect(TRUE);
llOwnerSay("Door Sensor Operational. Using channel " + (string)channel);
}

collision_start(integer total_number)
{
key id = llDetectedKey(0);
llWhisper(channel,(string)id);
}

on_rez(integer num) { llResetScript(); }
}
Daisy Rimbaud
Registered User
Join date: 12 Oct 2006
Posts: 764
01-30-2007 07:45
That is most amazingly helpful - many thanks ...