Advertisement
Shaka01

create tunnel pusher

Jan 15th, 2023
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. redstoneSide = "right"
  2. empty = false
  3. sleepCount = 0
  4. stop = false
  5.  
  6.  
  7. function toggleRedstone(redstoneSide)
  8.   local currentState = rs.getInput(redstoneSide)
  9.   if currentState then
  10.     rs.setOutput(redstoneSide, false)
  11.   else
  12.     rs.setOutput(redstoneSide, true)
  13.   end
  14. end
  15.  
  16.  
  17.  
  18. function out()
  19.     redstone.setOutput(redstoneSide, true)
  20.     sleep(0.5)
  21.     while rs.getInput("back") do
  22.         sleep(0.5)
  23.     end
  24.     turtle.place()
  25.     redstone.setOutput(redstoneSide, false)
  26.     sleep(0.5)
  27. end
  28.  
  29. function checkSlot(slot)
  30.     if turtle.getItemDetail(slot) then
  31.         empty = false
  32.     else
  33.         empty = true
  34.     end
  35. end
  36.  
  37.  
  38. function inc()
  39.     sleepCount = 0
  40.     redstone.setOutput(redstoneSide, true)
  41.     sleep(0.5)
  42.     redstone.setOutput(redstoneSide, false)
  43.     repeat
  44.         sleep(1)
  45.         sleepCount = sleepCount + 1
  46.         if sleepCount == 5 then
  47.             stop = true
  48.             break
  49.         end
  50.     until turtle.detect()
  51.     turtle.dig()
  52. end
  53.    
  54. repeat
  55.     checkSlot(1)
  56.     out()
  57.     checkSlot(1)
  58. until empty == true
  59.  
  60. while stop == false do
  61. inc()
  62. end
  63.  
  64. item = turtle.getItemDetail(1)
  65. count = item.count - 1
  66.  
  67.  
  68. term.clear()
  69. term.setCursorPos(1, 1)
  70. print("Finished " ..count.. " long tunnel.")
  71.  
  72.  
  73.  
  74.  
  75.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement