Advertisement
holtsoftware

Stairs

Jun 3rd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. local holeWidth = 5
  2. local height = 4
  3. local lend = false
  4.  
  5. function forward()
  6.     while turtle.detect() do
  7.         turtle.dig()
  8.     end
  9.     while turtle.attack() do
  10.     end
  11.     turtle.forward()
  12. end
  13.  
  14. function selectItem(name)
  15.     for i=1,16 do
  16.         turtle.select(i)
  17.         local data = turtle.getItemDetail()
  18.         if data and data.name == name then
  19.             return
  20.         end
  21.     end
  22. end
  23.  
  24. function doHeight()
  25.     for i=1,(height - 1) do
  26.         if turtle.detectUp() then
  27.             turtle.digUp()
  28.         end
  29.         turtle.up()
  30.     end
  31.     for i=1,(height - 1) do
  32.         turtle.down()
  33.     end
  34. end
  35.  
  36. function goDown()
  37.     local success, data = turtle.inspectDown()
  38.  
  39.     if success and data.name == "minecraft:bedrock" then
  40.         lend = true
  41.         print("hit bedrock")
  42.     elseif turtle.detectDown() then
  43.         turtle.digDown()
  44.         turtle.down()
  45.     else
  46.         turtle.down()
  47.     end
  48. end
  49.  
  50. while not lend do
  51.     for i=1,holeWidth do
  52.         if not lend then
  53.             doHeight()
  54.             forward()
  55.             turtle.turnRight()
  56.             turtle.turnRight()
  57.             selectItem("minecraft:oak_stairs")
  58.             turtle.place()
  59.             turtle.turnLeft()
  60.             turtle.turnLeft()
  61.             goDown()
  62.         end
  63.     end
  64.     if not lend then
  65.         doHeight()
  66.         forward()
  67.         turtle.turnRight()
  68.         turtle.turnRight()
  69.         selectItem("minecraft:oak_stairs")
  70.         turtle.place()
  71.         turtle.turnLeft()
  72.         turtle.turnLeft()
  73.         for i=1,3 do
  74.             doHeight()
  75.             turtle.turnRight()
  76.             for j=1,holeWidth+1 do
  77.                 forward()
  78.                 doHeight()
  79.             end
  80.         end
  81.  
  82.         turtle.turnRight()
  83.     end
  84. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement