Advertisement
Dorex

Untitled

Sep 24th, 2023
1,229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //#################################################################################################################################
  3. //
  4. // Detect Long or Short Touch
  5. //
  6. // Dorex Delicioso 2023
  7. //
  8. //#################################################################################################################################
  9.  
  10. integer DODEBUG = TRUE;
  11.  
  12. // ############################## VARIABLES ##############################
  13.  
  14. float touchEventTime;
  15.  
  16. // ############################## FUNCTIONS ##############################
  17.  
  18. sayDebug(string text){
  19.     if (DODEBUG){
  20.         llOwnerSay(text);
  21.     }
  22. }
  23.  
  24. shortTouch(key avId){
  25.     sayDebug("short Touch");
  26. }
  27.  
  28. longTouch(key avId){
  29.     sayDebug("long Touch");
  30. }
  31.  
  32. // ############################## DEFAULT STATE ##############################
  33.  
  34. default
  35. {  
  36.     on_rez(integer start) {
  37.         llResetScript();
  38.     }
  39.  
  40.     touch_start(integer a)
  41.     {
  42.         touchEventTime = llGetTime();
  43.     }
  44.  
  45.  
  46.     touch_end(integer num_detected){
  47.        
  48.         // how long is a long touch, in seconds
  49.         integer longTouchMinTime = 2;
  50.  
  51.         if (llGetTime()  > touchEventTime + longTouchMinTime){
  52.             longTouch(llDetectedKey(0));
  53.         } else {
  54.             shortTouch(llDetectedKey(0));
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement