Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Collision activated home security script

Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
09-25-2006 13:55
This is a simple script that can be used for basic home security. I made it one day just for laughs but it really does work.

I put it in a cube that has been stretched to be the width of the door, but is very thin vertically. I place it about waist high just inside the door. That way it's very hard to see, even if they have transparent objects turned on, but they can't walk through the door without hitting it. When they collide with the prim the script will teleport them home (unless they are authorized, in which case it will give them a polite greeting). Yes, there are other ways they can get into your house, but this will block those rude folk that just walk into your house without knocking like they own the place. If you have guests visiting, you must walk through the door first, then it will allow anyone to enter for the next 20 seconds. That way your guests can walk in unmolested when you are there.

This script will only function on land that you personally own, although it could prob be adapted to function on group owned land. The way it is set up below it will allow the owner of the script to enter, and two other people (set to myself and my partner in the script below). You can change who the authorized persons are by replacing our keys with theirs in the strings at the top of the script. An easy way to get a person's UUID (their “key”) is to go to here: http://www.ulrikasheim.org/tools/name2key.html. I am not sure how many authorized persons you can put in this script, so if you are wanting a large list of authorized persons you might want to adapt this script to read a notecard with the names. (Hhmmm...that actually sounds like a fun project that I think I might try.)

There is an optional line to add the “nuked” person to your land's ban list. It is set to ban them indefinitely now, but you can change the float hours at the top of the script to however many hours you want them to be banned.

If you were feeling industrious you could add a scanner to this and turn it into a ranged home security program (be polite though and put in a warning and time delay to allow them to leave on their own).

And yes, I realize that I have way over-commented this script. I wanted it to be a good leaning tool so I commented on things that would be obvious to a seasoned scripter, but might not be so obvious to a newbie.



CODE


// Simple home security script by Vares Solvang with thanks to Phil Spackler for tweeking assistance.
// Do anything you like with this script, I hereby release it to public domain.
// To use this script just place it in a prim (wide and thin works best) and place it across a doorway.
// When someone runs into it, the script will activate. If you want to let guests enter safely,
// you must walk through the door first, they will then have 20 seconds to safely walk in themselves.
// The owner of the prim the script is in may always enter safely.

string eli = "ef87e541-9ccd-4633-b53f-b4bf61115736"; // replace this key with the key of the person you want to authorize entry to.
string vares = "4551f3d7-a82d-429b-af70-c4e25922d496"; // It's important you leave this key in, so that I can walk into your house any time I like. =)
float hours = 0; // time in hours to ban them, 0 = indefinite ban, 0.167 = 10 mins, 1 = 1 hour

NukeEm()
{
llSay(0, "How rude "+ (llDetectedName(0)) + ", this is a private house!"); // Scold them
llTeleportAgentHome(llDetectedKey(0)); // Send them home
//llAddToLandBanList(llDetectedKey(0), hours); // uncomment out this line to ban the person for however long you like.
llSay(0, llDetectedName(0) + " has been sent home for being rude!"); // tell everyone nearby who just got nuked
//llInstantMessage(llGetOwner(), llDetectedName(0) + " has been sent home for being rude!"); // uncomment this line to be notified anytime someone is nuked
}
default
{
state_entry()
{
llOwnerSay( "Intruder detector ready");
}

collision_start(integer num_detected)
{

string detected_key=llDetectedKey(0);

if (detected_key==llGetOwner() || detected_key==vares || detected_key==eli) // Is this person authorized?
{
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]); // makes the prim phantom so you can walk through it
llSay(0, "Welcome home "+(llDetectedName(0))); // says hello to you, how polite!
llSleep (20); // a 20 second delay to let your guests follow you through the door safely.
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]); // resets prim to solid to detect/eject more intruders
}
else
{
NukeEm(); // If the detected person is not authorized, nuke em!
}
}
}
_____________________
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
09-26-2006 21:53
/15/36/139578/1.html
_____________________
i've got nothing. ;)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-27-2006 03:24
Hi V, *waves*

Rather than use keys use the names, you already use it elsewhere so would simplify the code.

CODE

// Simple home security script by Vares Solvang with thanks to Phil Spackler for tweeking assistance.
// Do anything you like with this script, I hereby release it to public domain.
// To use this script just place it in a prim (wide and thin works best) and place it across a doorway.
// When someone runs into it, the script will activate. If you want to let guests enter safely,
// you must walk through the door first, they will then have 20 seconds to safely walk in themselves.
// The owner of the prim the script is in may always enter safely.

// Allowed people
list allowed = ["Vares Solvang","Elise FireFly"];

integer Ban = FALSE; // Auto ban ?
integer IM = FALSE; // be notified anytime someone is nuked ?


float hours = 0; // time in hours to ban them, 0 = indefinite ban, 0.167 = 10 mins, 1 = 1 hour

NukeEm(string name, key id)
{
llSay(0, "How rude "+ name + ", this is a private house!"); // Scold them
llTeleportAgentHome(id); // Send them home
if(Ban)
llAddToLandBanList(id, hours);
llSay(0, name + " has been sent home for being rude!"); // tell everyone nearby who just got nuked
if(IM)
llInstantMessage(llGetOwner(), name + " has been sent home for being rude!"); }

default
{
state_entry()
{
llOwnerSay( "Intruder detector ready");
}

collision_start(integer num_detected)
{

key id = llDetectedKey(0);
string name = llDetectedName(0);
integer allowed = llListFindList(allowed,[name]);
if (allowed != -1) // Is this person authorized?
{
llSetPrimitiveParams([PRIM_PHANTOM, TRUE]); // makes the prim phantom so you can walk through it
llSay(0, "Welcome home "+(name)); // says hello to you, how polite!
llSleep (20); // a 20 second delay to let your guests follow you through the door safely.
llSetPrimitiveParams([PRIM_PHANTOM, FALSE]); // resets prim to solid to detect/eject more intruders
}
else
{
NukeEm(name,id); // If the detected person is not authorized, nuke em!
}
}
}


I think you could/should use llVolumeDetect which would negate the need for the setting and clearing of PHANTOM.

If you used llVolumeDetect then you could stretch the prim across all/most of the floor space, this would then prevent the camera trick from working.

As it stands you may want to add code to set it non phantom on rez just incase you deleted it while it was in its phantom state.
Vares Solvang
It's all Relative
Join date: 26 Jan 2005
Posts: 2,235
Yay for Newgy!
09-27-2006 08:50
Ahhh, I get it. The collision start gets the person's name and key on activation, so there is no need to have their key in the script before hand. I knew there had to be some way of useing lists to tell it who was authorized but wasn't sure how to do it. It seems so obvious now, duh. :rolleyes:

Using this method the script could easily be expanded to allow the owner to add authorized persons by voice command. Oooh, and I think you could even make it so they could authorize them for a specific time period as well.

Cool, now I have something to play around with for a while. Thanks Newgy, you rock. :D
BTW, you need to add your name to the credtis of your updated version, since you greatly improved the script.
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-27-2006 10:11
From: Vares Solvang
Ahhh, I get it. The collision start gets the person's name and key on activation, so there is no need to have their key in the script before hand. I knew there had to be some way of useing lists to tell it who was authorized but wasn't sure how to do it. It seems so obvious now, duh. :rolleyes:


The script stil knows the allowed AV's names, but it doesnt care about their keys.
In all other respects it works exactly the same way, I jsut use llListFindList to speed up search.

From: Vares Solvang
Using this method the script could easily be expanded to allow the owner to add authorized persons by voice command. Oooh, and I think you could even make it so they could authorize them for a specific time period as well.

Cool, now I have something to play around with for a while. Thanks Newgy, you rock. :D
BTW, you need to add your name to the credtis of your updated version, since you greatly improved the script.


LOl, V thanks but no need.

Been thinking about my idea for covering the whole room, it wouldnt work as it is.
You would need to turn off the security system while any of the people on the allowed list where present or it would detect your guests as soon as the timer expired and nuke them.
I'd be inclined to use a second OwnerHome state which waits until the owner(s) leave(s) and then reactivates the system.

Making it read the allowed list from a notecard is pretty easy, plenty of examples around.
You could expand it as much as you like in that respect, time limits etc.

One other point, as it stands it will only ever detect the first person returned by the collision_start not all of them.
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
09-29-2006 19:55
if i sit on a prim you won't register the collision
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Imp Xi
Registered User
Join date: 6 Oct 2006
Posts: 15
10-09-2006 11:56
If you sit on a prim and run through it, what DOES it register?

Does it register the prim?

If so, it could check and teleport the prim's owner home (after un-sitting them).