Jump to content
Sign in to follow this  
Dora Gustafson

Long touch detection

Recommended Posts

How to implement one more touch option:

// Long touch script by Dora Gustafson, Studio Dora 2012;

default
{
    touch_start(integer num) { llResetTime(); }
    touch_end(integer num)
    {
        if ( llGetTime() > 0.8 ) llOwnerSay("Was touched for more than 0.8 seconds");
        else llOwnerSay("Was clicked normally with a short touch");
    }
}

 

  • Thanks 2

Share this post


Link to post
Share on other sites

i've made simular script (just far more lines of code!) but figured its not validating simultanous touches so best purpose for is on HUDs where just a single user is assumed or an additional user handler needs to get implemented somehow.

Anyway great idea to reset the script time! =) 

Share this post


Link to post
Share on other sites

The worst that can happen if you get more touch events is that you get a short and not a long touch.
In that situation try again.
What are the odds for more avatars touching within 0.8 seconds anyway?

Share this post


Link to post
Share on other sites

Yes, you're right! It will just silently fail. Not sure tho how it works with multiple prims as well. I'm currently working on an asynchronous workaround using a timed calleback but it might lags for sure validating the avatars key, touch prim link number and touch counts or coordinates for gestures. That might be alot for a single script but i dont really expect more than 2-3 simultanous touches and so far it works well. 

Share this post


Link to post
Share on other sites

Or, if you're interested in detecting a double touch ...

default{	touch_start(integer num)	{		if (llGetAndResetTime() < 1.0)	//Choose a different time interval if 1 second isn't sensitive enough for you		{			llSay(0,"Double Touch");		}	}}

 

  • Thanks 1

Share this post


Link to post
Share on other sites

great, that is exactly what I need at this very moment :-)

May I add (for amateurs like me), that using touch instead of touch_end makes the script go on right after the set time,without waiting for the release of the mouse button.

Share this post


Link to post
Share on other sites


Mikki Miles wrote:

great, that is exactly what I need at this very moment :-)

May I add (for amateurs like me), that using touch instead of touch_end makes the script go on right after the set time,without waiting for the release of the mouse button.

That's an interesting wrinkle.  The touch event is not triggered by either the start or the end of a mouse action, but by the fact that the mouse button is still down.  So, if you start the clock with llResetTime in a touch_start event and measure it in a touch event, which keeps firing over and over and over again, it won't be long before llGetTime() > 0.8, whether you let go of the mouse button or not.  You just have to be careful not to put anything else in the touch event unless you want it to keep repeating too, so don't write something like

 

touch (integer num){    if (llGetTime() > 0.8)    {        llSay(0,"It's time to move!");        llSetPos( llGetPos() + <5.0,0.0,0.0>*llGetRot() );    }}

 :smileylol:

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...