Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Detecting Avitar On Touch

Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
08-02-2004 18:19
I was wondering if there was a way to detect who touches an object. I"m using touch_start(integer num_detected) {} on multiple objects with scripts linked together. And it would be helpful to detect who's clicking. I though maybe num_detected would pass the the clickers user ID, but the integer seem to only return the value true.

if I understand the function touch_start correctly, the function is only called when some one touches and object. So what the point of num_Detected, can't I assume if the function was called, it's true. meaning that their no reason to ever compare, look, or use the value num_detected?
Ironchef Cook
-
Join date: 23 Jun 2003
Posts: 574
08-02-2004 18:45
touch_start(integer blah)
{
llSay(0, llDetectedName(0));
}
Al Bravo
Retired
Join date: 29 Jun 2004
Posts: 373
08-02-2004 18:48
Check out the llDetectedKey() function.

cycle through num_detected and you can get the key of everybody touching the object at that moment

CODE

integer c;
for(c=0; c < num_detected; ++c)
llWhisper(0, (string)llDetectedKey(c));
Ironchef Cook
-
Join date: 23 Jun 2003
Posts: 574
08-02-2004 18:51
Ya there's no real use for the integer in the touch_start event. It probably carried over from the sensor event. Since the sensor can pick up multiple av's, you can do a loop such as this
sensor(integer total)
{
integer i;
for (i=0; i<total; i++)
{
llSay(0, llDetectedName(i));
}
}
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
08-02-2004 19:20
isit posible for two people to be touch_start the item at the exact time? Ie num_detected > 1 ?
Hiro Pendragon
bye bye f0rums!
Join date: 22 Jan 2004
Posts: 5,905
08-02-2004 21:41
From: someone
Originally posted by Kurt Zidane
isit posible for two people to be touch_start the item at the exact time? Ie num_detected > 1 ?


Not simultaneously. Remember a state language such as LSL runs a state like an event. The event touch causes the touch function to work. One person touches then the next, even if a millisecond apart.
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
08-02-2004 22:02
From: someone
Originally posted by Kurt Zidane
isit posible for two people to be touch_start the item at the exact time? Ie num_detected > 1 ?


Actually, it is possible. I found that using llMinEventDelay to delay event execution *didnt* cause touch_start events to pile up, rather, at the end of the delay, only one touch_start was executed, but its integer parameter was > 1.
==Chris