the standard way:
ignore all but the first person to touch if there are simultaneaous touches
touch_start( integer vIntTouches ){
//-- all llDetected* functions use 0
}
the safe way
loop through the number of touches to process all simultaneous touches
touch_start( integer vIntTouches ){
while (~(--vIntTouches)){ //-- loops through backwards less code
//-- llDetected* Functions use vIntTouches
}
}
other loops will work, just remember that detect* uses the index, not the count, so the indexes will be from 0 to (count-1)
IMPORTANT NOTE ABOUT "SIMULTANEITY":
touch events have a trigger time of 0.1sec when the script is NOT processing anything. so simultaneous means within .1sec of the first touch.
IF however, the script is processing code, the touch event gets added to the queue, and further touches after that are added to it's event slot, until the touch event executes... this can mean several touches can stack up (but only one per avatar). in the below example, any touch within 30 seconds is simultaneous for this purpose
as an example, have several people touch a prim with the following script immediately after it starts.
default{
state_entry(){
llSay( 0, "collecting touches for the next 30 seconds" );
llSleep( 30.0 );
}
touch_start( integer vIntTouches ){
llSay( 0, "I detected " + (string)vIntTouches + " different touches"
while (~(--vIntTouches)){
llSay( 0, llDetectedName( vIntTouches ) );
}
}
}
what this means:
you should ALWAYS loop through your touch event properly, but especially if you have code that takes a long time to process, or have many high traffic users.
even if it's only set to respond to the owner (so not expected that others would be touching it constantly), someone else could lock the owner out of their own script by rapidly clicking on the 'standard' example
just for fun
a super fast loop:
@loop
if (~(--vIntTouches)){
//-- use llDetected* with (vIntTouches);
jump loop;
}
is logically the same as, but faster than:
integer index;
for( index = vIntTouches - 1; index != -1; index = index - 1 )
//-- llDetected*( index );
}