Guest User

Mindcrack-Inspired Branch Mining Script

a guest
Jan 5th, 2013
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. distanceFromHome = 0
  2. currentDigDepth = 0
  3. torchSlot = 16
  4. function turn(turnFor)
  5. if turnFor > 0 then
  6. lastTurn = 1
  7. for i=1,turnFor do
  8.     turtle.turnRight()
  9. end
  10. elseif turnFor < 0 then
  11. lastTurn = -1
  12. turnFor = -1 * turnFor
  13. for i=1,turnFor do
  14. turtle.turnLeft()
  15. end
  16. end
  17. end
  18. function dig(digDistance)
  19. for currentDigDepth=1,digDistance do
  20. while turtle.detectDown() or turtle.detect() or turtle.detectUp() do
  21.     turtle.digUp()
  22.     turtle.digDown()
  23.     turtle.dig()
  24.     sleep(.2)
  25. end
  26. move(1)
  27. end
  28. end
  29. function fuelCheck()
  30.     -- if(turtle.getFuelLevel() <= distanceFromHome) then
  31.         -- if(turtle.getItemCount(16) > 0) then
  32.             -- turtle.select(16)
  33.         -- else
  34.             -- turtle.select(16)
  35.             -- print("Need Fuel!")
  36.             -- getHome()
  37.             -- exit()
  38.         -- else
  39.         -- turtle.refuel(1)
  40.         -- end
  41.     -- end
  42. end
  43. function getHome()
  44. end
  45. function move(moveDistance, moveDirection)
  46. if(moveDirection == 0 or moveDirection == nil) then
  47.     for currentMoveDistance=1,moveDistance do
  48.         turtle.forward()
  49.         if(currentMoveDistance % 8 == 0) then
  50.             turtle.select(torchSlot)
  51.             turtle.placeDown()
  52.         end
  53.            
  54.         fuelCheck()
  55.     end
  56. elseif(moveDirection == 1) then
  57.     for currentMoveDistance=1,moveDistance do
  58.         turtle.up()
  59.         fuelCheck()
  60.     end
  61. elseif(moveDirection == -1) then
  62.     for currentMoveDistance=1,moveDistance do
  63.         turtle.down()
  64.         fuelCheck()
  65.     end
  66. end
  67. moveDirection = nil
  68. end
  69.  
  70. term.clear()
  71. term.setCursorPos(1,1)
  72. write("How much space between rows? ")
  73. rowSpace = tonumber(io.read()) + 1
  74. write("How many rows? ")
  75. rowCount = tonumber(io.read())
  76. write("How deep should the branches be? ")
  77. branchDepth = tonumber(io.read())
  78.  
  79. for currentRow=1,rowCount do
  80.     dig(rowSpace)
  81.     turn(-1)
  82.     dig(branchDepth + 2)
  83.     turn(2)
  84.     move(branchDepth + 2)
  85.     dig(branchDepth + 4)
  86.     turn(2)
  87.     move(branchDepth + 4)
  88.     if(currentRow ~= rowCount) then
  89.         turn(1)
  90.     else
  91.         turn(-1)
  92.     end
  93. end
  94. move(rowCount * rowSpace)
  95. turn(2)
  96. print("Finished.")
Add Comment
Please, Sign In to add comment