Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Owner only

James Melson
Registered User
Join date: 28 Oct 2007
Posts: 11
01-09-2008 03:05
Hello guys.
I have a question: If I have a door and I want it to just open for the owner, what should I do?
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
01-09-2008 03:35
look at the touch event, llDetectedKey() and llGetOwner().
James Melson
Registered User
Join date: 28 Oct 2007
Posts: 11
01-09-2008 06:05
What value should I use at the llDetectedKey when touching?
Daten Thielt
Registered User
Join date: 1 Dec 2006
Posts: 104
01-09-2008 06:22
touch_start(integer t)
{
if(llGetOwner() == llDetectedKey(0)
{
do stuff
}
}
James Melson
Registered User
Join date: 28 Oct 2007
Posts: 11
01-09-2008 06:30
Ah thanks I think I got it right now.
Anyway shouldn't it be:

touch_start(integer t)
{
if (llGetOwner() == llDetectedKey(t))
{
do stuff
}
}

??? :P
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
01-09-2008 08:36
From: James Melson
Ah thanks I think I got it right now.
Anyway shouldn't it be:

touch_start(integer t)
{
if (llGetOwner() == llDetectedKey(t))
{
do stuff
}
}

??? :P


Typos are what makes us human :)
Kahiro Watanabe
Registered User
Join date: 28 Sep 2007
Posts: 572
01-09-2008 10:21
Daten's code is ok.

The "integer t" parameter in "touch_start()" event is a click counter that counts how many times the prim containing the script was left clicked at the same time.

It's strange that many people touches a door at the same time. See this for more information: http://www.lslwiki.net/lslwiki/wakka.php?wakka=touch_start

If you are paranoid about this, you will have to make a "for" sentence to evaluate each case, but it's absurd.

Edit: llDetectedKey(t) would only evaluate the last case.
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
01-09-2008 10:31
llDetectedKey(t - 1) would evaluate the last case.

Handling multiple touches may be kind of absurd, not totally necessary, but there are the absurd cases where it might be desirable. Stupid things like, what if someone was griefing you by keeping their hand on your door so you couldn't open it. Anyway, example

touch_start(integer t)
{
key owner = llGetOwner();
integer i;
for(i = 0; i < t; i++)
{
if(llDetectedKey(i) == owner)
{
do stuff
}
}
}
_____________________
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
01-09-2008 10:32
From: Kahiro Watanabe
Daten's code is ok.


It's strange that many people touches a door at the same time. See this for more information: http://www.lslwiki.net/lslwiki/wakka.php?wakka=touch_start

If you are paranoid about this, you will have to make a "for" sentence to evaluate each case, but it's absurd.

Edit: llDetectedKey(t) would only evaluate the last case.


Agrred, and even been paranoid doesnt help, you can only spot the first 16, just let them click again.
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-09-2008 20:11
you wouldn't want to use llDetected( t ), unless you decremnt or loop through the total because 't' in this case is the total, and not the index...

a slightly simplified version with loop goes like this
CODE

touch_start( integer vIntTouches ){
do{
--vIntTouches;
if (llDetectedKey( vIntTouches ) == llGetOwner()){
//-- do stuff
}
}while(vIntTouches);
}


but that's only if you're really worried about multiple simultaneous touches with .1 seconds (the default event triggering time for touch according to lslwiki.net) otherwise just use
CODE

touch_start( integer vIntNull ){ //-- I use the null name to denote values I'm ignoring in events
if (llDetectedKey( 0 ) == llGetOwner()){
//--do stuff
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
James Melson
Registered User
Join date: 28 Oct 2007
Posts: 11
01-11-2008 13:28
Thanks for the support guys.