Advertisement
Xenogami

shaftBot

Sep 9th, 2013
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.90 KB | None | 0 0
  1. -- Simple shaft mining program by Xenogami
  2.  
  3. -- If the inventory is full, put down a chest and empty inventory.
  4. local function dropStash()
  5.     if turtle.getItemCount(16) > 0 then
  6.         turtle.select(1)
  7.         turtle.placeDown()
  8.         for a=2,16 do
  9.             turtle.select(a)
  10.             turtle.dropDown()
  11.         end
  12.         turtle.select(1)
  13.     end
  14. end
  15.  
  16. -- Makes sure the turtle can move forward, else digs away obstacle.
  17. local function moveForward()
  18.     while not turtle.forward() do
  19.         turtle.dig()
  20.     end
  21. end
  22.  
  23. -- Mines then check if inventory is full.
  24. local function mineTime()
  25.     turtle.dig()
  26.     turtle.digUp()
  27.     turtle.digDown()
  28.     dropStash()
  29. end
  30.  
  31.  
  32. -- Turns right and move to start of next shaft.
  33. local function turnRight()
  34.     turtle.turnRight()
  35.     mineTime()
  36.     moveForward()
  37.     mineTime()
  38.     moveForward()
  39.     mineTime()
  40.     moveForward()
  41.     mineTime()
  42.     turtle.turnRight()
  43. end
  44.  
  45. -- Turns left and move to start of next shaft.
  46. local function turnLeft()
  47.     turtle.turnLeft()
  48.     mineTime()
  49.     moveForward()
  50.     mineTime()
  51.     moveForward()
  52.     mineTime()
  53.     moveForward()
  54.     mineTime()
  55.     turtle.turnLeft()
  56. end
  57.  
  58. -- Digs out a double length shaft with a space in the center for the return shaft.
  59. local function digShaft()
  60.     for a=1,121 do
  61.         mineTime()
  62.         moveForward()
  63.     end
  64. end
  65.  
  66. -- Digs out the first and last shaft.
  67. local function shortShaft()
  68.     for a=1,60 do
  69.         mineTime()
  70.         moveForward()
  71.     end
  72. end
  73.  
  74. -- Track what direction the turtle needs to turn.
  75. local function findFacing()
  76.     if facing == 1 then
  77.         turnRight()
  78.         facing = 2
  79.     else
  80.         turnLeft()
  81.         facing = 1
  82.     end
  83. end
  84.  
  85. -- Initializes tracking bit to control what direction to face when starting a new shaft.
  86. facing = 1
  87.  
  88. moveForward()
  89. mineTime()
  90. turtle.turnLeft()
  91. shortShaft()
  92. for b=1,5 do
  93.     findFacing()
  94.     digShaft()
  95. end
  96. findFacing()
  97. shortShaft()
  98. mineTime()
  99. turtle.forward()
  100. if facing == 1 then
  101.     turtle.turnLeft()
  102. else
  103.     turtle.turnRight()
  104. end
  105. for b=1,20 do
  106.     mineTime()
  107.     moveForward()
  108. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement