Guest User

boo-urns

a guest
Feb 10th, 2025
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. private var lastOnUpdate = null;
  2. private var lastOnShow = null;
  3. private var lastLapAlert = null;
  4. private var hotkeyReps = 0;
  5. private var haveHotkey = 0;
  6.  
  7. private var cfgHotkey; // 0=disabled, 1=once, 2=twice
  8.  
  9. private const hotkeyThreshold = 2000; // ms
  10.  
  11. function onTimerLap() {
  12. lastLapAlert = System.getTimer();
  13. //...
  14. }
  15.  
  16. function onUpdate(dc) {
  17. var now = System.getTimer();
  18. lastOnUpdate = now;
  19. //...
  20. }
  21.  
  22. function onShow() {
  23. var now = System.getTimer();
  24. // ignore first onShow() within 8 seconds after lap alert
  25. if (lastLapAlert != null && lastOnShow != null && lastLapAlert > lastOnShow && now - lastLapAlert < 8000) {
  26. lastLapAlert = null;
  27. } else if (lastOnUpdate != null && cfgHotkey) {
  28. if (now - lastOnUpdate <= hotkeyThreshold * cfgHotkey) {
  29. hotkeyReps++;
  30. if (hotkeyReps >= cfgHotkey) {
  31. hotkeyReps = 0;
  32. haveHotkey = true;
  33. // trigger hotkey action
  34. // ...
  35. }
  36. }
  37. }
  38. lastOnShow = now;
  39. return false;
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment