Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Touch_start for only one person?

Aedroogo Hosoi
Registered User
Join date: 22 Aug 2006
Posts: 12
09-20-2006 21:59
Hello all,

I'm trying to script the touch_start event so that only the person currently engaging the object (i.e paid to use it) can trigger the touch_start event. Could someone tell me any way to keep outside/non-paying agents from touching/interfering with the object?

Thanks in advance for any insight you all may have.
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
09-20-2006 22:17
Only way I can think of off hand..
When someone pays the unit, store their name or their key into a variable

Then when the touch_start event triggers.. check to see if the llDetectedKey(0) == Your_Variable

That way you can filter out all other agents
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-21-2006 00:57
From: Aakanaar LaSalle
Only way I can think of off hand..
When someone pays the unit, store their name or their key into a variable

Then when the touch_start event triggers.. check to see if the llDetectedKey(0) == Your_Variable

That way you can filter out all other agents


Aakanaar's right, or at least its the same idea I use in my mastermind and hangman games.
Aedroogo Hosoi
Registered User
Join date: 22 Aug 2006
Posts: 12
09-21-2006 08:01
Got it. That makes perfect sense. Thank you!
Gaius Goodliffe
Dreamsmith
Join date: 15 Jan 2006
Posts: 116
09-21-2006 11:59
CODE
key customer;

default
{
money(key id, integer amount)
{
customer = id;
}

touch_start(integer count)
{
integer i;
for ( i = 0 ; i < count ; ++i )
{
if ( llDetectedKey(i) == customer )
{
// do stuff here
}
}
}
}

touch_start events with llDetectedKey(0) make me cringe -- I like my code to work correctly all the time, not just "usually", thank you very much. Lag is bad enough without it being made worse by sloppy coding.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
09-21-2006 13:01
From: Gaius Goodliffe
touch_start events with llDetectedKey(0) make me cringe -- I like my code to work correctly all the time, not just "usually", thank you very much. Lag is bad enough without it being made worse by sloppy coding.

Eh. Depends on the application. Make the user wait until no one else is touching the object at the same time? Sometimes acceptable.
Aakanaar LaSalle
Registered User
Join date: 1 Sep 2006
Posts: 132
09-21-2006 13:19
From: Gaius Goodliffe
touch_start events with llDetectedKey(0) make me cringe -- I like my code to work correctly all the time, not just "usually", thank you very much. Lag is bad enough without it being made worse by sloppy coding.


It really depends.. two people triggering a touch_start at the same time is very rare, and for most applications having someone click a second time once in a great while is perfectly fine.

It's sort of the same thing with a piece of code I did recently which checks a date for the number of days since 2000-01-01. It counts for leapyears. Someone posted (correctly I might add) that it wasn't perfect as it didn't count for dates previous to 2000, and would also break in 2100 when the next leapyear annomoly would occure.

SL started in 2003, so I don't ever expect to be checking previous to 2000, and by the time 2100 comes around, i really doubt that script would still be in use.

So, while the other person's code might be more accurate.. is it feasible? eh.. Your code does handle multiple touch_starts at the same time.. but at a slight cost of resources.. Is it really worth the extra coding? That depends on what is relying on it.