Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

need help with a key card system

Jaxith Zapatero
Registered User
Join date: 24 Dec 2008
Posts: 20
02-13-2009 01:56
im trying to make a security door that opens to key card that a person is wearing. ive got a basic idea but its flawed cause anyone can open the door is someone is nearby with a key card. i want it to be 5 levels of security so yea. help would be much appreciated
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
02-13-2009 02:06
have the keycard identify the owner and compare that with the toucher
_____________________
L$ is the root of all evil
videos work! thanks SL :)
Jaxith Zapatero
Registered User
Join date: 24 Dec 2008
Posts: 20
02-13-2009 02:30
ok thats kindof what i thought i had to do but no clue how to do it
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
02-13-2009 02:57
If you're looking for someone to make this script for you, Scripting Tips is the wrong place to look. Try posting in "Products Wanted".

This forum is for gettting help with writing your own scripts... but we're not here to give you a free working example of the script you desire.
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Jaxith Zapatero
Registered User
Join date: 24 Dec 2008
Posts: 20
02-13-2009 03:07
thats not what im asking. giving help would be like "use this code and this code". then i have to figure out how they work an stuff.
Yingzi Xue
Registered User
Join date: 11 Jun 2008
Posts: 144
02-13-2009 05:00
This can be done many different ways. These are some of the methods that can be used to detect the keycard and allow entry based on criteria...

llSensorRepeat (http://wiki.secondlife.com/wiki/LlSensorRepeat)
llListen (http://wiki.secondlife.com/wiki/LlListen)
collision_start (http://wiki.secondlife.com/wiki/Collision_start)
llDetectedKey (http://wiki.secondlife.com/wiki/LlDetectedKey)
llGetKey (http://wiki.secondlife.com/wiki/LlGetKey)
Jaxith Zapatero
Registered User
Join date: 24 Dec 2008
Posts: 20
02-13-2009 05:39
i was looking at those and thought maybe. thanks for the help
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-13-2009 08:18
How would I do it?

I'm wearing the card as an attachment, so the door can't use a sensor to detect the card, unfortunately (the card can sense the door, though, but I'm not doing it that way). This means the door and the card have to talk to each other.

The door knows who's just touched it. I can grab the toucher's uuid thus:
CODE
touch_start(integer num_detected){
key av = llDetectedKey(0);
}
The card knows who it belongs to; llGetOwner(); is lsl for "what is my owner's uuid?".

We've got to find a nice obscure channel on which the door and the key can communicate. I'd be inclined to adapt this useful snippet from http://wiki.secondlife.com/wiki/DialogMenus:
CODE
integer channel_dialog; // top of script in variables

channel_dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
//put this in state_entry() or somewhere like that.
}
so that the door talks and listens on channel based not on its own uuid (as in this example) but on the uuid of whoever has just touched it.

My card knows it belongs to me, so I can make it communicate on the same channel by adapting the snippet slightly differently to use my uuid.

Then, if someone touches the door, the door can work out what channel to use and then say, "any cards around belonging to the av who has just touched me?" or words to that effect and start listening for a reply.

If it gets a positive response in the next few seconds, it shuts down the listener and opens the door, and if it doesn't it just stops listening and waits for the next customer.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-13-2009 08:43
I've done this one before. On interesting events (touch, etc.) have the door send out a general query on a common channel. If you really want secure, you could include some random data that the door remembers, so outdated replies can't simply be re-used.

Have all nearby cards take the door's query, add some kind of passcode, hash the result, and add it and the door's original query data to a reply. The door, of course, also knows the passcode and can verity the signature hash.

The door can either cache valid responses and remember them for a while (but it pretty much has to re-query every time it sees someone who ISN'T authorized), or simply look for one from the person it was trying to authorize (e.g. the toucher).

You don't have to include the owner in the reply. Just use 'llGetOwnerKey()' to find the owner of the speaking object.
Jaxith Zapatero
Registered User
Join date: 24 Dec 2008
Posts: 20
02-13-2009 09:01
well Innula Zenovka your response actually makes sense to me. i understand what to do for it a little more now but im still kinda having troubles putting it together.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-13-2009 11:56
From: Jaxith Zapatero
well Innula Zenovka your response actually makes sense to me. i understand what to do for it a little more now but im still kinda having troubles putting it together.
Why not post what you've got so far? Or tell us what the problem area is? You said you didn't want the script writing for you and it's a bit difficult to know what specific help you want.
Jaxith Zapatero
Registered User
Join date: 24 Dec 2008
Posts: 20
02-13-2009 12:13
ok well i deleted my first attempt since it was completly wrong so going off what you said already this is what i have so far

integer channel_dialog;



default
{

state_entry()
{
channel_dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
llListen(-83,"", NULL_KEY, "";);
}
touch_start(integer num_detected)
{
key av = llDetectedKey(0);
}
listen(integer channel, string name, key id, string message)
{

}

}


now im not sure if this is set up right or not but yea. also i really dont know what to do for what its sapossed to listen to or what to actually set in the card.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-13-2009 13:03
From: Jaxith Zapatero
ok well i deleted my first attempt since it was completly wrong so going off what you said already this is what i have so far

integer channel_dialog;



default
{

state_entry()
{
channel_dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
llListen(-83,"", NULL_KEY, "";);
}
touch_start(integer num_detected)
{
key av = llDetectedKey(0);
}
listen(integer channel, string name, key id, string message)
{

}

}


now im not sure if this is set up right or not but yea. also i really dont know what to do for what its sapossed to listen to or what to actually set in the card.
Well, let's see...

You want to grab the toucher's key in the touch_start event, which you have done, but then.. if you are following my suggestion.. you want to use it to generate a channel based on the key, and say something on it, in the hope of getting a message back from the card, if the av has one. So I would do something like this:
CODE
integer mychannel;  // declared as a global variable so we can use it anywhere in the script
key av; // likewise
integer handle; // we're going to use this to turn the listen on and off


default
{
state_entry()
{

}

touch_start(integer total_number)
{
av = llDetectedKey(0); // grab the key of whoever just touched me
mychannel = ( -1 * (integer)("0x"+llGetSubString((string)av,-5,-1)) );//create a channel based on the av's key -- the channel changes each time someone touches me
handle = llListen(mychannel, "", NULL_KEY, ""); // create a listener using that channel
llListenControl(handle, TRUE);//and turn it on
llSay(mychannel, (string)av); // and say the av's key on it, since we need to say something
llSetTimerEvent(5.0); // and start a timer going, so we don't keep the listen open longer than we need

}

listen(integer channel, string name, key id, string message)
{
if (llGetOwnerKey(id) !=av) // if the message isn't from an item belonging to whoever just touched me
{
return; // ignore it and don't do anything else
}
else // ah! it's on my special channel and it's from an item belonging to whoever touched me
{
llListenControl(handle, FALSE);//so i can turn the listener off
llSetTimerEvent(0.0); // and turn off the timer, since I don't need it
// do stuff here to open the door

}
}

timer()
{
llListenControl(handle, FALSE); // not heard anything, assume I'm not going to
llInstantMessage(av, "Sorry, but I'm not letting you in because you're not wearing a key card");
llSetTimerEvent(0.0); // and switch off the timer
}

}

Now all you need to do is write a script for the key card to make it listen for messages on a channel based on its owner's uuid and respond when it gets one. And put stuff in the door script to open the door, of course.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
02-13-2009 14:49
From: Innula Zenovka

......
CODE


touch_start(integer total_number)
{
av = llDetectedKey(0); // grab the key of whoever just touched me
mychannel = ( -1 * (integer)("0x"+llGetSubString((string)av,-5,-1)) );//create a channel based on the av's key -- the channel changes each time someone touches me
handle = llListen(mychannel, "", NULL_KEY, ""); // create a listener using that channel
llListenControl(handle, TRUE);//and turn it on
llSay(mychannel, (string)av); // and say the av's key on it, since we need to say something
llSetTimerEvent(5.0); // and start a timer going, so we don't keep the listen open longer than we need

}

listen(integer channel, string name, key id, string message)
{
if (llGetOwnerKey(id) !=av) // if the message isn't from an item belonging to whoever just touched me
{
return; // ignore it and don't do anything else
}
else // ah! it's on my special channel and it's from an item belonging to whoever touched me
{
llListenControl(handle, FALSE);//so i can turn the listener off
llSetTimerEvent(0.0); // and turn off the timer, since I don't need it
// do stuff here to open the door

}
}

timer()
{
llListenControl(handle, FALSE); // not heard anything, assume I'm not going to
llInstantMessage(av, "Sorry, but I'm not letting you in because you're not wearing a key card");
llSetTimerEvent(0.0); // and switch off the timer
}

}



I'm still quite new to LSL, so I'm curious about the use of llListenControl in situations like this. Since it's highly unlikely that the listen event will ever receive a message on mychannel that DOESN'T result from the touch_start event in this script, why is llListenControl necessary? Is there a good reason why you can't just let the object listen on mychannel all the time?
Jaxith Zapatero
Registered User
Join date: 24 Dec 2008
Posts: 20
02-13-2009 15:32
From: Rolig Loon
I'm still quite new to LSL, so I'm curious about the use of llListenControl in situations like this. Since it's highly unlikely that the listen event will ever receive a message on mychannel that DOESN'T result from the touch_start event in this script, why is llListenControl necessary? Is there a good reason why you can't just let the object listen on mychannel all the time?


what i am trying to get made here is a key card door script that can be set to 5 different levels. if it listens to only one av's channel then it wont work for anyone else.
Jaxith Zapatero
Registered User
Join date: 24 Dec 2008
Posts: 20
02-13-2009 15:54
From: Innula Zenovka
Well, let's see...

You want to grab the toucher's key in the touch_start event, which you have done, but then.. if you are following my suggestion.. you want to use it to generate a channel based on the key, and say something on it, in the hope of getting a message back from the card, if the av has one. So I would do something like this:
CODE
integer mychannel;  // declared as a global variable so we can use it anywhere in the script
key av; // likewise
integer handle; // we're going to use this to turn the listen on and off


default
{
state_entry()
{

}

touch_start(integer total_number)
{
av = llDetectedKey(0); // grab the key of whoever just touched me
mychannel = ( -1 * (integer)("0x"+llGetSubString((string)av,-5,-1)) );//create a channel based on the av's key -- the channel changes each time someone touches me
handle = llListen(mychannel, "", NULL_KEY, ""); // create a listener using that channel
llListenControl(handle, TRUE);//and turn it on
llSay(mychannel, (string)av); // and say the av's key on it, since we need to say something
llSetTimerEvent(5.0); // and start a timer going, so we don't keep the listen open longer than we need

}

listen(integer channel, string name, key id, string message)
{
if (llGetOwnerKey(id) !=av) // if the message isn't from an item belonging to whoever just touched me
{
return; // ignore it and don't do anything else
}
else // ah! it's on my special channel and it's from an item belonging to whoever touched me
{
llListenControl(handle, FALSE);//so i can turn the listener off
llSetTimerEvent(0.0); // and turn off the timer, since I don't need it
// do stuff here to open the door

}
}

timer()
{
llListenControl(handle, FALSE); // not heard anything, assume I'm not going to
llInstantMessage(av, "Sorry, but I'm not letting you in because you're not wearing a key card");
llSetTimerEvent(0.0); // and switch off the timer
}

}

Now all you need to do is write a script for the key card to make it listen for messages on a channel based on its owner's uuid and respond when it gets one. And put stuff in the door script to open the door, of course.



ok i can understand what it is doing here but it also confuses me. most of that code is new to me. now correct me if im wrong but if i set the channel in this instead of it getting the channel from the av i would be able to set different security levels right? cause as far as i can understand right now this just basicly sends a message on the channel saying that the one who touched it is the one with the card and i can either use the av channel or a set channel. if im wrong please tell me. right now i am trying to get the card done up
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-13-2009 15:55
From: Rolig Loon
I'm still quite new to LSL, so I'm curious about the use of llListenControl in situations like this. Since it's highly unlikely that the listen event will ever receive a message on mychannel that DOESN'T result from the touch_start event in this script, why is llListenControl necessary? Is there a good reason why you can't just let the object listen on mychannel all the time?
I'm doing it that way..... and I hope this answers Jaxith's question, too ... because I'm creating a separate listener each time someone touches it. I touch it and it creates a special channel to check if I've got a card, and then junks the channel when it's finished. And then you touch it and creates and uses another channel based on your uuid. If I didn't shut the listener down, I would soon end up getting a script error because I was listening on too many channels.

Certainly I could do it the way Hewee suggests.. just listen on one channel all the time and check that the owner of the object that replies is the same av how just touched me. Even then, though, I think it's good practice to shut down the listener when it's not needed.
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-13-2009 16:00
From: Jaxith Zapatero
ok i can understand what it is doing here but it also confuses me. most of that code is new to me. now correct me if im wrong but if i set the channel in this instead of it getting the channel from the av i would be able to set different security levels right? cause as far as i can understand right now this just basicly sends a message on the channel saying that the one who touched it is the one with the card and i can either use the av channel or a set channel. if im wrong please tell me. right now i am trying to get the card done up
It depends on how you're doing your security levels.. I don't really see how the channel affects that one way or the other. Presumably either the door checks the av against a list of people once it knows with whom it is dealing ("Ah, this is Innula.. let me look her up on my list.. ";) or the card says what my level is when it identifies me to the door ("This is Innula's card and she is security level such-and-such";).
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
02-13-2009 16:08
I understand that, but it looks to me as if whoever touches the object generates mychannel, a channel number based on that person's UUID. The object then says the toucher's key on mychannel, thus activating its own listen event. In the listen event, it checks to be sure that it's receiving a message from the person who touched it (Well, duh. Who else is going to be sending a message on this special channel?). If so, then it unlocks the door. I don't see a key card in this script. I just see someone touching a door and being admitted if she's the person who touched it.

I'm actually mostly curious about what llListenControl does, but that curiosity led me to wonder about the script as a whole. I don't see (1) why this script goes to all the trouble of creating a special channel to listen to itself and (2) what the llListenControl function has to do with any of it.

I'm clearly missing something here. (Probably more than one thing. It's been a long day ..... ;) )
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-13-2009 16:34
From: Rolig Loon
I understand that, but it looks to me as if whoever touches the object generates mychannel, a channel number based on that person's UUID. The object then says the toucher's key on mychannel, thus activating its own listen event.
No.. prims can't hear themselves. To activate the listen event, it has to get a response from another prim that's listening on mychannel. Which will be the key card.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
02-13-2009 16:49
I keep it archived:

Reply from Kelly Linden on 11/13/07 to Scripters mailing list:

"You are pretty close. The actual order of events is:
1. Chat that is said gets added to a history.
2. A script that is running and has a listen event will ask the history
for a chat message during its slice of run time.
3. When the script asks the history for a chat message the checks are
done in this order:
- channel
- self chat (objects can't hear themselves)
- distance/RegionSay
- key
- name
- message
4. If a message is found then a listen event is added to the event queue.

The key/name/message checks only happen at all if those are specified of
course.

So, the most efficient way is llRegionSay on a rarely used channel."
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-13-2009 17:06
I'm not sure the reference to "objects" there is, in fact, correct. Certainly a prim can't talk to itself -- regardless of whether the listener is in the same script or another script in the same prim -- but I'm pretty sure that a script in one prim can hear another prim in the same linkset.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
02-13-2009 17:06
From: Innula Zenovka
No.. prims can't hear themselves. To activate the listen event, it has to get a response from another prim that's listening on mychannel. Which will be the key card.


Oh. /me hides her face.

I knew I was missing something. OK, so back to the question that got me into this thread in the first place..... What's the extra value added here by using llListenControl? Unless you anticipate having >64 key cards yelling at the same time, can't you just keep listening on each value of mychannel? Why turn off the listen handles?
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
02-13-2009 17:18
I may have misunderstood it, but I was under the impression that if I don't close the listener, the channels on which I'm listening will just stack up, so the the 65th av who touches it will crash it.

Afterthought.

Sorry.. I didn't mention the main reason for using llListenControl.

The way it was explained to me is that whenever anything's said in the region, the sim has to run various tests for all scripts with an open listener, to see which, if any, script needs to do something about it. Almost messages will fall at the first hurdle for my door -- they are on the wrong channel, so they can't be for the door -- but why waste processing resources having the door check anything at all other than for the few seconds when it might expect to receive a message (just after someone's touched it)?
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
02-13-2009 17:22
From: Innula Zenovka
I'm not sure the reference to "objects" there is, in fact, correct. Certainly a prim can't talk to itself -- regardless of whether the listener is in the same script or another script in the same prim -- but I'm pretty sure that a script in one prim can hear another prim in the same linkset.

Just depends on your definition of "object". Object in Kelly's post is indeed referring to "prim" and not link set.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
1 2