Guest User

Untitled

a guest
Oct 16th, 2022
1,495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. -- executes function after 10 seconds
  2. timer:Simple(10, function()
  3.     print("This function was delayed for 10 seconds!")
  4. end)
  5.  
  6. -- executes function 5 times every 10 seconds
  7. timer:Create("SomeUniqueTimerName", 10, 5, function()
  8.     print(os.time())
  9. end)
  10.  
  11. -- executes every 10 seconds
  12. -- reps is 0 => infinite repetitions
  13. timer:Create("SomeUniqueTimerName", 10, 0, function()
  14.     -- do smth here
  15. end)
  16.  
  17. -- delay is 0 => executes each tick
  18. timer:Create("SomeUniqueTimerName", 0, 0, function()
  19.     -- do smth here
  20. end)
  21.  
  22. -- removes any timer
  23. -- returns `true` if the given timer existed else `false`
  24. timer:Remove("SomeUniqueTimerName") -> bool
  25.  
  26. -- returns `true` if the given timer exists else `false
  27. timer:Exists("SomeUniqueTimerName") -> bool
  28.  
  29. -- restart any timer - drops current repetitions to original
  30. -- explanation:
  31. -- if base reps = 10 and the given timer executed already 4 times then this method do from 6 remaining reps to 10
  32. -- returns `true` if the given timer successfully restarted (if existed) else `false`
  33. timer:Start("SomeUniqueTimerName") -> bool
  34.  
  35. -- pause the timer
  36. -- returns `true` if the given timer successfully paused
  37. -- returns `false` if the given timer doesn't exists or this one already paused
  38. timer:Pause("SomeUniqueTimerName") -> bool
  39.  
  40. -- unpause the timer
  41. -- returns `true` if the given timer successfully unpaused
  42. -- returns `false` if the given timer doesn't exists or this one wasn't paused/already unpaused
  43. timer:UnPause("SomeUniqueTimerName") -> bool
  44.  
  45. -- toggle the pause state of timer
  46. -- returns `true` if the given timer successfully unpaused
  47. -- returns `false` if the given timer doesn't exists
  48. timer:Toggle("SomeUniqueTimerName") -> bool
  49.  
  50. -- returns amount of time (in a seconds) before the given timer will execute the function for the last time and be removed
  51. -- if the given timer doesn't exists then returns `nil`
  52. timer:TimeLeft("SomeUniqueTimerName") -> int
  53.  
  54. -- returns amount of time (in a seconds) before the given timer will execute the function for the next time
  55. -- if the given timer doesn't exists then returns `nil`
  56. timer:NextTimeLeft("SomeUniqueTimerName") -> int
  57.  
  58. -- returns amount after how many repetitions the given timer will execute the function for the last time and be removed
  59. -- if the given timer doesn't exists then returns `nil`
  60. timer:RepsLeft("SomeUniqueTimerName") -> int
Advertisement
Add Comment
Please, Sign In to add comment