Advertisement
ceed24

turtle Digging stairs ComputerCraft

Oct 22nd, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. -- Requires:
  2. -- mining turtle
  3. -- Slot 1, Coal
  4. -- Slot 2, Stairs if you want him to place Stairs
  5.  
  6. function digMyStairs()
  7. local action=true
  8. local steps=0
  9. NeedFuel()
  10. turtle.forward()
  11. turtle.digDown()
  12. turtle.down()
  13.     while action  do
  14.         local success, data = turtle.inspectDown()
  15.         if success then
  16.             if data.name~="minecraft:bedrock" then
  17.             steps=steps+1
  18.                     for i=1 , 4 do
  19.                         turtle.dig()
  20.                         turtle.forward()
  21.                     end
  22.                     for i=1 , 3 do
  23.                         turtle.back()
  24.                     end
  25.                     turtle.digDown()
  26.                     turtle.down()
  27.             else action=false
  28.             placeStairs(steps)
  29.             end
  30.     else action=false  
  31.  
  32.         end
  33.     end
  34. end
  35.  
  36. function placeStairs(s)
  37.  
  38. turtle.select(2)
  39. turtle.turnLeft()
  40. turtle.turnLeft()
  41. turtle.up()
  42. turtle.placeDown()
  43. for i=1 , s do
  44.                         turtle.up()
  45.                         turtle.forward()
  46.                         turtle.placeDown()
  47. end
  48. turtle.forward()
  49. end
  50.  
  51. function NeedFuel()
  52.     if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1  then
  53.  
  54.     turtle.select(1)
  55.             if turtle.refuel() then
  56.                 print("Fuel level is: ", ( turtle.getFuelLevel() / turtle.getFuelLimit() ) * 100, "%")
  57.             else
  58.                 print("Can't refuel ,Place some Coal in the 1st Slot")
  59.             end
  60.     else print("Fuel level is: ", ( turtle.getFuelLevel() / turtle.getFuelLimit() ) * 100, "%","We can still move", turtle.getFuelLevel(), "blocks")
  61. end
  62. end
  63. digMyStairs()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement