Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llTouch_end to link message sometimes counts once

RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
07-21-2005 21:19
I'm trying to make a thing that you can aim by touching it on prim the prim sends a link message and if the main prim recieves a message from that pieces link number it knows how far and what direction to move. I'm using touch end because I figured it only happens once per click well bout a third of the time it seems to get that one click message twice I even added a half second sleep between after it sends the message thinking that would eliminate any possibility of getting a double click but that didn't change anything. anyone know how to fix that?
Rayve Mendicant
Scripts for L$5 billion
Join date: 12 Mar 2005
Posts: 90
07-21-2005 22:28
I've had this issue before. I added a debouncer code (used in electrical push buttons to avoid double taps), and it didn't seem to correct the problem. Adding a sleep is a simple debouncer actually and would logically be an easy way to solve it. However I think the problem is in how LSL actually takes in this data. It doesn't seem to take each touch one at a time. This is evident by the integer num_detected parameter. That might be your problem here. Might be registering more than one touch at a time and performing the action both times.

maybe this will correct it?

CODE
 touch_end(integer detected_num)
{
integer i = 0;
for (i=0;i<detected_num;i++)
{
if (llDetectedKey(i) == user)
{
//insert operation here
}
}
}


That may have nothing to do with it. I dunno. It's 1:30 AM here and I'm exhausted and delirious :)
_____________________
_______________________

Rayve Mendicant
Second Evolution

"Darwin ain't got nothin' on this"
RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
07-22-2005 01:00
I ended up doing this but it limits it to one touch per second and adds a timer which is probably not good. because theres four of these per catapult times 8 for the event 24 timers running. just for aiming. Maybe I could set them to only run a couple seconds and shut down.
CODE

default
{
state_entry()
{
llPassTouches(FALSE);
llSetTimerEvent(1);
}
touch_end(integer total_number)
{
// llSay(0,(string)llGetLinkNumber());
total_number = FALSE;
llPassTouches(FALSE);

if(count != oldcount){
llMessageLinked(LINK_ROOT,4444,"left",NULL_KEY);
}
oldcount = count;
llSetColor(<1,0,0>,ALL_SIDES);
llSleep(0.5);
llSetColor(<1,1,1>,ALL_SIDES);
//llWhisper(0,(string)count);
}
timer()
{
count = count + 1;
if(count >= 99){
count = 1;
}

}}


so it only lets the message go through if count isn't the same as the one before it. but if you touch it just as it changes I imagine you still get a double touch.
Rayve Mendicant
Scripts for L$5 billion
Join date: 12 Mar 2005
Posts: 90
07-22-2005 11:25
A normal type of doubletap would be overcome by this method, but the way the touch events take data, it won't help.

at the moment, the method I described is the only thing I can think of. I usually don't have this problem, but I do remember having it once.
_____________________
_______________________

Rayve Mendicant
Second Evolution

"Darwin ain't got nothin' on this"