Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Touch owneronly dostuff

Thili Playfair
Registered User
Join date: 18 Aug 2004
Posts: 2,417
05-20-2006 04:34
err well the topic kinda the question , trying to make a door that works for owner only , but kinda baffled how to do it,

This one half work, trouble is it doesnt bother checking if the owner actually is clicking

CODE

integer on=FALSE;
default
{
state_entry()
{
if(llDetectedOwner(0) == llGetOwner())
{
//do stuff
}
}
touch_start(integer total_number)
{
if(on==TRUE)
{
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
on=FALSE;
}
else
{
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,-PI/4>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
on=TRUE;
}

}
}


Tried to add getowner but didnt get it to work for both only one so when i did click it went 1 way, if anyone else not owner clicked it went the other :p eh, im not to good with these things.

Anyone know what to put in to fix it?
Tip Baker
Registered User
Join date: 12 Nov 2005
Posts: 100
05-20-2006 05:09
Within the touch event, you need to compare the person touching the door, llDetectedKey(x), with the owner of the door, llGetOwner(). If they are the same, do things.

(Untested)
CODE

integer on=FALSE;
default
{
state_entry()
{

}
touch_start(integer total_number)
{
If(llGetOwner() == llDetectedKey(0))
{
if(on==TRUE)
{
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,PI/4>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
on=FALSE;
}
else
{
rotation rot = llGetRot();
rotation delta = llEuler2Rot(<0,0,-PI/4>);
rot = delta * rot;
llSetRot(rot);
llSleep(0.25);
rot = delta * rot;
llSetRot(rot);
on=TRUE;
}
}
}
}


Because you do not have a loop to check for multiple touches at the same time, you may have problems if two people touch the door at exactly the same time, but this shouldnt happen very often.

hope that helps

Tip
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
05-20-2006 05:11
From: Thili Playfair
CODE

state_entry()
{
if(llDetectedOwner(0) == llGetOwner())
{
//do stuff
}
}

The llDetected... are only returning sensible results in situations/events where something actually gets detected. I.e. they'll work in touch() event but not during state_entry()

in addition, DetectedOwner() is a call that returns owner of detected object, so not really something which would apply.

Simple way to do it:
CODE

touch_start(integer total_number) {

if( llDetectedkey(0) != llGetOwner() ) return;

// do normal stuff for owner here
}

...this will make the touch even only work for the object owner and no one else.
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
05-20-2006 05:11
CODE

touch_start (integer touches)
{
if (llDetectedKey (0) == llGetOwner ())
{
llShout (0, "I'm being touched by my owner!");
}
}

I'm sure you can work out the rest now. :)
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
05-20-2006 05:22
Similar to what's already been suggested... but I would have gone for this...

CODE
touch_start(integer total_number)
{
if(llDetectedKey(total_number - 1) == llGetOwner())
{
// do stuff
}
}
...does this not accomodate multiple touches?
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
05-20-2006 05:29
From: Pale Spectre
Similar to what's already been suggested... but I would have gone for this...

CODE
touch_start(integer total_number)
{
if(llDetectedKey(total_number - 1) == llGetOwner())
{
// do stuff
}
}
...does this not accomodate multiple touches?


No, it only accomodates the last touch of multiple touches. If 3 people touched the door at once, the door might or might not open, depending upon if the owner was the 3rd person to touch the door simulataneously.
Thili Playfair
Registered User
Join date: 18 Aug 2004
Posts: 2,417
05-23-2006 06:38
\o/ thanks guys, helped me a ton fixing things an additions badly needed :q
Julia Banshee
Perplexed Pixie
Join date: 16 Jan 2006
Posts: 97
05-23-2006 11:27
Uffda... here's the right way to do this:

CODE
touch_start(integer count)
{
integer i;
for ( i = 0 ; i < count ; ++i )
{
if ( llDetectedKey(i) == llGetOwner() )
{
// do your thing
}
}
}


Use this, and the door will always open or close when touched by the owner. (In all the previous scripts posted here, it may ignore touches from the owner if someone else touches it as well -- lag is bad enough, let's not actually start ignoring messages that are delivered.)