Guest User

Timer for ComputerCraft

a guest
Feb 5th, 2025
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | Gaming | 0 0
  1. -- CC Timer Made by MCWendiz NO HOURS --
  2. -- 2025 --
  3.  
  4. local side = "left" --choose side of input
  5. local args = {...} --time
  6. local res = true -- u can pause by using redstoune on computer
  7. local monitors = { peripheral.find("monitor") } -- finding monitor
  8.  
  9. -- u can fix if u want --
  10.  
  11. function timer()
  12. for i = 1,2 do
  13. shell.run("redpulse back 1")
  14. end
  15. end
  16.  
  17. if args[1] == nil or args[1] == "help" then
  18. print("timer <time>") -- if u made mistakes
  19. return
  20. else
  21.  
  22. local delay = tonumber(args[1]) --fix troubles with understanding int`s
  23. args[1] = tonumber(args[1])
  24. args[2] = 0
  25.  
  26. while res == true do
  27. if not rs.getInput("top") then
  28. if args[1]>59 then --this for making understandable time
  29. args[2] = math.floor(args[1] / 60)
  30. args[1] = args[1] - (args[2]*60)
  31. end
  32. if args[1] == 0 and args[2]>0 then
  33. args[2] = args[2]-1
  34. args[1] = 59
  35. end
  36. for _, monitor in pairs(monitors) do --writtind on all monitors u have connecting
  37. monitor.clear()
  38. monitor.setTextScale(5)
  39. monitor.setCursorPos(5,3)
  40. monitor.setTextColor(colors.white)
  41. monitor.write(args[2] ..":")
  42. if args[1]<10 then
  43. monitor.write(0)
  44. monitor.write(args[1])
  45. else
  46. monitor.write(args[1])
  47. end
  48. end
  49. term.clear() --for watching in terminal how many seconds to next minut left
  50. term.setCursorPos(1,1)
  51. print(args[1])
  52. if args[1] == 0 and arg[2] == 0 then
  53. res = false
  54. end
  55. args[1] = args[1]-1
  56. sleep(1) -- this is the args[1]
  57. end
  58. if rs.getInput("top") then --pausing
  59. monitor.clear()
  60. monitor.setTextScale(1)
  61. monitor.setCursorPos(1,1)
  62. monitor.setTextColor(colors.red)
  63. monitor.write("OFF")
  64. monitor.setCursorPos(1,2)
  65. monitor.write("pause")
  66. term.clear()
  67. term.setCursorPos(1,1)
  68. print(" I HAVE PAUSED THE PROGRAM SIR!!")
  69. shell.run("ls")
  70. sleep(3)
  71. end
  72. end
  73. end
Tags: timer
Advertisement
Add Comment
Please, Sign In to add comment