CTekkLP

Wither Redstone Clock v2

May 16th, 2021 (edited)
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. --#################################################################################################################
  2. --                                         Computer Wither Redstone Clock
  3. --                                                     v. 2.0
  4. --                                                (c)2021 CTekkLP
  5. --#################################################################################################################
  6.  
  7.  
  8. --#################################################################################################################
  9. --                                                 Local Variables
  10. --#################################################################################################################
  11.  
  12. local sideSkull = "top"             --Redstone side of the Computer for Skulls
  13. local sideSoulSand = "bottom"       --Redstone side of the Computer for SoulSand
  14. local timeSkull = 1                 --Time for Skulls
  15. local timeSoulSand = 1.2            --Time for SoulSand
  16. local timeBetweenRuns = 2           --Time between Runs
  17.  
  18. --#################################################################################################################
  19. --                                                    Function´s
  20. --#################################################################################################################
  21.  
  22. print("How many Runs?")
  23. local runs = read()
  24. local num = tonumber(runs)
  25.  
  26. function waiting(time)
  27.     local myTimer = os.startTimer(time)
  28.     while true do
  29.         local event, timerID = os.pullEvent("timer")
  30.         if timerID == myTimer then break end
  31.     end
  32. end
  33.  
  34. function actRed()
  35.     redstone.setOutput(sideSoulSand, true)
  36.     waiting(timeSoulSand)
  37.     redstone.setOutput(sideSoulSand, false)
  38.  
  39.     redstone.setOutput(sideSkull, true)
  40.     waiting(timeSkull)
  41.     redstone.setOutput(sideSkull, false)
  42. end
  43.  
  44. --#################################################################################################################
  45. --                                                     Main
  46. --#################################################################################################################
  47.  
  48. if num ~= nil then
  49.     for i= 1, runs, 1 do
  50.         print("Start Run ", i)
  51.         actRed()
  52.         waiting(timeBetweenRuns)
  53.     end
  54. else
  55.     print("Error")
  56. end
Add Comment
Please, Sign In to add comment