Advertisement
Kijan

Doubleclick

Apr 9th, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. function onLoad(save_state)
  2.   self.createButton({
  3.     click_function = "click",
  4.     function_owner = self,
  5.     label          = "Click ME",
  6.     position       = {0,1,0}
  7.   })
  8. end
  9.  
  10. function click()
  11.   local firstClick = Timer.destroy("firstClick")
  12.   local secondClick = Timer.destroy("secondClick")
  13.   if firstClick == false then
  14.     Timer.create({
  15.       identifier     = "firstClick",
  16.       function_name  = "oneClick",
  17.       function_owner = self,
  18.       delay          = 1
  19.     })
  20.   else
  21.     Timer.create({
  22.       identifier     = "firstClick",
  23.       function_name  = "dud",
  24.       function_owner = self,
  25.       delay          = 2
  26.     })
  27.     if secondClick == false then
  28.       Timer.create({
  29.         identifier     = "secondClick",
  30.         function_name  = "doubleClick",
  31.         function_owner = self,
  32.         delay          = 1
  33.       })
  34.     else
  35.       print("3+")
  36.     end
  37.   end
  38. end
  39.  
  40. function oneClick()
  41.   print("oneClick")
  42. end
  43.  
  44. function doubleClick()
  45.   print("doubleClick")
  46. end
  47.  
  48. function dud() end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement