Advertisement
Guest User

mineshaft

a guest
Nov 27th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. --Improvements to add:
  2. --Make sure the turtle has enough fuel and torches to do a run
  3. --Doesn't drop fuel in the chest
  4.  
  5. local function prerunCheck()
  6.    
  7. end
  8.  
  9. local function storeAll()
  10.     for i = 1,16 do
  11.         turtle.select(i)
  12.         turtle.drop()
  13.     end
  14. end
  15.  
  16. local function store()
  17.     for i =1,16 do
  18.         details = turtle.getItemDetail(i)
  19.         if details.name ~= "minecraft:torch" then
  20.             turtle.select(i)
  21.             turtle.drop()
  22.         end
  23.     end
  24. end
  25.  
  26. local function home()
  27.     lastPosX = movement.x
  28.     lastPosY = movement.y
  29.     lastPosZ = movement.z
  30.     lastPhase = phase
  31.  
  32.     if phase == 3 then
  33.         movement.gotoZXY(-length, 0, 1)
  34.         movement.gotoZXY(0, 0, 0)
  35.     else
  36.         movement.gotoXZY(0, 0, 0)
  37.     end
  38.    
  39.     movement.turnTo(0)
  40.     store()
  41.    
  42.     if lastPhase == 3 then
  43.         movement.gotoYZX(lastPosY, -length, lastPosX)
  44.         movement.gotoYZX(lastPosY, lastPosZ, lastPosX)
  45.     else
  46.         movement.gotoYZX(lastPosY, lastPosZ, lastPosX)
  47.     end
  48. end
  49.  
  50. args = {...}
  51. torchSpace = 9
  52. phase = 1
  53. gap = 3
  54.  
  55. if args[1] == nil then
  56.     print("Usage: mineshaft (length)")
  57.     return
  58. end
  59. length = tonumber(args[1])
  60. os.loadAPI("movement")
  61. os.loadAPI("util")
  62. turtle.select(1)
  63. movement.init()
  64. movement.up()
  65.  
  66. local function digColumn()
  67.     movement.digForward()
  68.     turtle.digUp()
  69.     turtle.digDown()
  70.     if util.isFull() then
  71.         home()
  72.     end
  73. end
  74.  
  75. for i = 1,length do
  76.     digColumn()
  77.     if i % torchSpace == 0 then
  78.         util.select("torch")
  79.         turtle.placeDown()
  80.         turtle.select(1)
  81.     end
  82. end
  83.  
  84. phase = 2
  85. movement.turnLeft()
  86.  
  87. for i = 0,gap do
  88.     digColumn()
  89. end
  90.  
  91. movement.turnLeft()
  92.  
  93. util.select("torch")
  94. turtle.placeDown()
  95.  
  96. phase = 3
  97. for i = 1,length do
  98.     digColumn()
  99.     if i % torchSpace == 0 then
  100.         util.select("torch")
  101.         turtle.placeDown()
  102.         turtle.select(1)
  103.     end
  104. end
  105.  
  106. phase = 4
  107. movement.gotoXZY(0, 0, 0)
  108. movement.turnTo(0)
  109. storeAll()
  110. movement.turnTo(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement