Advertisement
holtsoftware

Construct Storage Shaft

Jun 3rd, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.00 KB | None | 0 0
  1. local chest1, chest2, pipe, ladder = 1, 2, 3, 4
  2. local lend = false
  3.  
  4. function forward()
  5.     while not turtle.forward() do
  6.         while turtle.attack() do
  7.         end
  8.         while turtle.dig() do
  9.         end
  10.     end
  11. end
  12.  
  13. function clearLine()
  14.     for f=0,3 do
  15.         if turtle.detect() then
  16.             turtle.dig()
  17.         end
  18.         forward()
  19.     end
  20. end
  21.  
  22. function turnRight()
  23.     turtle.turnRight()
  24.     if turtle.detect() then
  25.         turtle.dig()
  26.     end
  27.     forward()
  28. end
  29.  
  30. function turnLeft()
  31.     turtle.turnLeft()
  32.     if turtle.detect() then
  33.         turtle.dig()
  34.     end
  35.     forward()
  36. end
  37.  
  38. function clear()
  39.     clearLine()
  40.     turnRight()
  41.     turtle.turnRight()
  42.     clearLine()
  43.     turnLeft()
  44.     turtle.turnLeft()
  45.     clearLine()
  46.     turnRight()
  47.     turtle.turnRight()
  48.     clearLine()
  49.     turnLeft()
  50.     turtle.turnLeft()
  51.     clearLine()
  52. end
  53.  
  54. function clearGotoStart()
  55.     turtle.turnLeft();
  56.     turtle.turnLeft();
  57.     for v=0,3 do
  58.         turtle.forward()
  59.     end
  60.     turtle.turnRight();
  61.     for q=0,3 do
  62.         turtle.forward()
  63.     end
  64.     turtle.turnRight();
  65. end
  66.  
  67. function goDown()
  68.     local success, data = turtle.inspectDown()
  69.  
  70.     if success and data.name == "minecraft:bedrock" then
  71.         lend = true
  72.         print("hit bedrock")
  73.     elseif turtle.detectDown() then
  74.         turtle.digDown()
  75.         turtle.down()
  76.     else
  77.         turtle.down()
  78.     end
  79. end
  80.  
  81. function selectItem(name)
  82.     for i=1,16 do
  83.         turtle.select(i)
  84.         local data = turtle.getItemDetail()
  85.         if data and data.name == name then
  86.             return
  87.         end
  88.     end
  89. end
  90.  
  91. function selectChest()
  92.     selectItem("minecraft:chest")
  93. end
  94.  
  95. function selectLadder()
  96.     selectItem("minecraft:ladder")
  97. end
  98.  
  99. function selectPipe()
  100.     selectItem("ExtraUtilities:pipes")
  101. end
  102.  
  103. function selectGlowstone()
  104.     selectItem("minecraft:glowstone")
  105. end
  106.  
  107.  
  108. function placeChestLayer()
  109.     --- Line 1
  110.     selectChest()
  111.     forward()
  112.     forward()
  113.     turtle.placeUp()
  114.     forward()
  115.     forward()
  116.     selectLadder()
  117.     turtle.placeUp()
  118.     turtle.turnRight()
  119.     forward()
  120.     turtle.turnRight()
  121.     turtle.turnRight()
  122.     turtle.place()
  123.     turtle.turnLeft()
  124.     --- Line 2
  125.     forward()
  126.     selectGlowstone()
  127.     turtle.placeUp()
  128.     forward()
  129.     selectChest()
  130.     turtle.placeUp()
  131.     forward()
  132.     forward()
  133.     turtle.turnLeft()
  134.     forward()
  135.     turtle.turnLeft()
  136.     --- Line 3
  137.     selectChest()
  138.     turtle.placeUp()
  139.     forward()
  140.     turtle.placeUp()
  141.     forward()
  142.     selectPipe()
  143.     turtle.placeUp()
  144.     forward()
  145.     turtle.turnRight()
  146.     turtle.turnRight()
  147.     turtle.place()
  148.     turtle.turnLeft()
  149.     turtle.turnLeft()
  150.     selectChest()
  151.     turtle.placeUp()
  152.     forward()
  153.     turtle.placeUp()
  154.     forward()
  155.     turtle.turnRight()
  156.     forward()
  157.     turtle.turnRight()
  158.     --- Line 4
  159.     forward()
  160.     forward()
  161.     selectChest()
  162.     turtle.placeUp()
  163.     forward()
  164.     selectGlowstone()
  165.     turtle.placeUp()
  166.     forward()
  167.     turtle.turnLeft()
  168.     forward()
  169.     turtle.turnLeft()
  170.     --- Line 5
  171.     selectChest()
  172.     forward()
  173.     forward()
  174.     turtle.placeUp()
  175.     forward()
  176.     forward()
  177. end
  178.  
  179. while not lend do
  180.     clear()
  181.     clearGotoStart()
  182.     goDown()
  183.     if not lend then
  184.         clear()
  185.         clearGotoStart()
  186.         placeChestLayer()
  187.         clearGotoStart()
  188.         goDown()
  189.     end
  190. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement