Touch Time Advanced

Date 2010/5/12 5:04:01 | Topic: Time

Have 2 different things happen for regular Touch and Long Touch, (hold for 2 seconds.)

If avatar Touches like normal they get TOUCH 1

If avatar Touches and holds for 2+ seconds they get TOUCH 2

float mintime 2.0//how many seconds to get long touch option

float t;
integer donenow FALSE;
 
default
{
    
on_rez(integer start_param)
    {
        
llResetScript();
    }
    
    
state_entry()
    {
        
donenow FALSE;
    }
    
    
touch_start(integer num_detected)
    {
        
llGetTime();
    }
    
    
touch(integer num_detected)
    {
        
float tempsecs llGetTime() - t;
        if ((
tempsecs >= mintime) && (donenow == FALSE))
        {
            
donenow TRUE;
            
llSay(0"Long Touch detected, you may release Touch now.");
        }
    }
    
    
touch_end(integer num_detected)
    {
        
float secs llGetTime() - t;
        
//llOwnerSay((string)secs + " seconds between touch_start and touch_end"); //debug
        
if (secs >= mintime//greater than or equal
        
{
            
llSay(0"Touch 2"); //debug
        
}
        else 
//regular touch
        
{
            
llSay(0"Touch 1"); //debug
        
}
        
donenow FALSE;
    }
}




This script comes from Alicia Stella Design - Best Tip Jars in Second Life
http://www.aliciastella.com

The URL for this script is:
http://www.aliciastella.com/modules/AMS/article.php?storyid=33