Advertisement
Rovetown

repeater-settings-library

Oct 9th, 2024 (edited)
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. -- repeater_lib.lua
  2.  
  3. -- Define the delay in seconds for each repeater step
  4. local repeaterDelays = {
  5. [0] = 0.0, -- No Delay (0 ticks)
  6. [1] = 0.1, -- 1 Tick (1 tick)
  7. [2] = 0.2, -- 2 Ticks (2 ticks)
  8. [3] = 0.3, -- 3 Ticks (3 ticks)
  9. [4] = 0.4 -- 4 Ticks (4 ticks)
  10. }
  11.  
  12. -- Function to get the sleep time based on repeater ticks
  13. -- Accepts the tick setting as an argument
  14. local function getSleepTime(ticks)
  15. -- Return the corresponding seconds or 0 if invalid
  16. return repeaterDelays[ticks] or 0.0
  17. end
  18.  
  19. -- Public function to set the repeater delay
  20. local function repeaterSetting(tickSetting)
  21. local delayTime = getSleepTime(tickSetting)
  22. os.sleep(delayTime) -- Sleep for the duration of the repeater delay
  23. end
  24.  
  25. -- Return the public API
  26. return {
  27. repeaterSetting = repeaterSetting
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement