Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Locking doors Help

Trevor Boffin
Just plain ol' me
Join date: 27 Jul 2004
Posts: 16
08-08-2004 18:08
Ok, the following is the script that came in my door, and I am looking for help on a couple of things. First, how do I lock it? And seccond, is it possible to script it so that two people could share the lock/unlock feature (person A locks it, Person B comes by later and unlocks it)?

CODE

string gLockedBy = "";
integer gLockChannel = 243;

default
{
state_entry ()
{
llSay(0, "Door 1.0");
llListen(gLockChannel, "", NULL_KEY, "");
state closed;
}
}

state closed
{
listen(integer channel, string name, key id, string message)
{
if (channel == gLockChannel)
{
if (message == "")
{
gLockedBy = "";
//llTrigerSound("door unlock", 10.0);
llSay(0,"unlocked");
}
else
{
gLockedBy = message;
//llTriggerSound("door lock", 10.0);
llSay(0, "locked");
}
}
}

touch_start(integer total_number)
{
string name = llDetectedName (0);
if (name =gLockedBy || gLockedBy == "")
{
llTriggerSound ("Door open", 0.5);

rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0, 0, PI/4>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta* rot;
llSetRot(rot);
state open;
}
else
{
llTriggerSound("Door knock", 0.5);
}
}
}

state open
{
touch_start(integer num)
{
llTriggerSound("Door close", 0.5);
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0, 0, -PI/4>);
rot = delta * rot;
llSetRot (rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
state closed;
{
{
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
08-09-2004 07:31
need another "=" operator in the if statement under the touch event... sorry out of time to otherwise comment, it's bedtime!

Boso
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
08-09-2004 09:25
"x = 3" sets the value of "x" to 3.
"x == 3" checks to see if the value of "x" is 3.
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog
Tiger Crossing
The Prim Maker
Join date: 18 Aug 2003
Posts: 1,560
08-09-2004 09:52
And remember, locking doors is just a way of telling people you don't want them to come in. It won't stop them. There are any number of ways to get inside sealed areas.

Just don't want people to think locks do what they do in RL. :)
_____________________
~ Tiger Crossing
~ (Nonsanity)
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
08-09-2004 10:53
Try saying lock on channel 243. Don't ask me how to do that. I'd use an object. I don't like lock scripts like this, because people can use a channel scanners and find out what channel the script responds to. It's better to rig all the doors and windows, extra to except values in passing, but only by objects owned by you. and then rig a single object to lesson on a public channel, and pass values to the other objects. Then rig that object can run a check on user keys. Put the user keys in a list in that object, or read from a note card.
Bosozoku Kato
insurrectionist midget
Join date: 16 Jun 2003
Posts: 452
08-10-2004 05:52
You can now (couple patches ago I think it was) chat on high channels.

syntax is simply: /chan string

/732 hi
..says "hi" on channel 732.

err I think that's how it works, blah now I forget -- price I pay for not testing things when they come out (and commiting them to memory).

Boso
Catherine Omega
Geometry Ninja
Join date: 10 Jan 2003
Posts: 2,053
08-10-2004 07:29
From: someone
Originally posted by Kurt Zidane
I don't like lock scripts like this, because people can use a channel scanners and find out what channel the script responds to.


Trevor, you can set it to only listen to the owner, or objects owned by owner by changing your listen() event like so:

CODE
listen(integer channnel, string name, key id, string m)
{
// only listen to owner or objects that belong to owner.
if (llGetOwnerKey(id) == llGetOwner())
{
// put everything in YOUR listen event in here.
}
}
_____________________
Need scripting help? Visit the LSL Wiki!
Omega Point - Catherine Omega's Blog