Advertisement
CTekkLP

Wither Redstone Clock v3

May 16th, 2021
1,141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.17 KB | None | 0 0
  1. --#################################################################################################################
  2. --                                         Computer Wither Redstone Clock
  3. --                                                     v. 3.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. local rsBridgeName = "rsBridge_0"   --Name of the RS Bridge
  18.  
  19. --#################################################################################################################
  20. --                                                 Load Peripherals
  21. --#################################################################################################################
  22.  
  23. local rsBridge = peripheral.wrap(rsBridgeName)
  24.  
  25. --#################################################################################################################
  26. --                                                    FunctionΒ΄s
  27. --#################################################################################################################
  28.  
  29. print("How many Runs?")
  30. local runs = read()
  31. local num = tonumber(runs)
  32.  
  33. function waiting(time)
  34.     local myTimer = os.startTimer(time)
  35.     while true do
  36.         local event, timerID = os.pullEvent("timer")
  37.         if timerID == myTimer then break end
  38.     end
  39. end
  40.  
  41. function actRed()
  42.     redstone.setOutput(sideSoulSand, true)
  43.     waiting(timeSoulSand)
  44.     redstone.setOutput(sideSoulSand, false)
  45.  
  46.     redstone.setOutput(sideSkull, true)
  47.     waiting(timeSkull)
  48.     redstone.setOutput(sideSkull, false)
  49. end
  50.  
  51. function checkItems()
  52.     soul_sand = rsBridge.getItem({name="minecraft:soul_sand"})
  53.     if soul_sand ~= nil then
  54.         if tonumber(soul_sand[1]["amount"]) < 4 then
  55.             error("Not enough Soul Sand! min 4")
  56.         end
  57.     else
  58.         error("Not enough Soul Sand! min 4")
  59.     end
  60.  
  61.     ws_skull = rsBridge.getItem({name="minecraft:wither_skeleton_skull"})
  62.     if ws_skull~= nil then
  63.         if tonumber(ws_skull[1]["amount"]) < 3 then
  64.             error("Not enough Wither Skeleton Skulls! min 3")
  65.         end
  66.     else
  67.         error("Not enough Wither Skeleton Skulls! min 3")
  68.     end
  69. end
  70.  
  71. --#################################################################################################################
  72. --                                                     Main
  73. --#################################################################################################################
  74.  
  75. if num ~= nil then
  76.     for i= 1, runs, 1 do
  77.         checkItems()
  78.         print("Start Run ", i)
  79.         actRed()
  80.         waiting(timeBetweenRuns)
  81.     end
  82. else
  83.     print("Error")
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement