Advertisement
buffsovernexus

Untitled

May 10th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. --[[
  2.  
  3. - StripMiner v0.1 -
  4.  
  5. Goals: Will strip mine up to 64 blocks away
  6.  
  7. --]]
  8.  
  9. -- Starting Location (Base)
  10. local start_x, start_y, start_z = 634, 10, 1353
  11.  
  12. -- Current Location
  13. local x, y, z = start_x, start_y, start_z
  14.  
  15. -- Logic: As long as we're inside of the min and maximums... we're okay.
  16. while turtle.getFuelLevel() > 1000 and isInventoryFull do
  17.  
  18. -- Step 1: Determine if the turtle found a block...
  19. if turtle.detect() then
  20. -- It did... Dig it.
  21. turtle.dig()
  22. else
  23. -- It didn't... Move forward.
  24. turtle.forward()
  25. x += x
  26. end
  27.  
  28.  
  29. end
  30.  
  31. -- Logic: When its low on fuel or is full... Go back to base by retracing steps.
  32. while reachedBase == false do
  33. -- Take the current location and create a loop to go back...
  34. local isX = false
  35. -- Determine if the turtle moved in the X or Z location.
  36. if x > start_x or x < start_x then
  37. isX = true
  38. end
  39.  
  40. if isX then
  41. -- They are AHEAD of the start location. Move BACK.
  42. while x > start_x do
  43. turtle.back()
  44. end
  45. -- They are BEHIND the start location. Move FORWARD.
  46. while x < start_x do
  47. turtle.forward()
  48. end
  49. end
  50.  
  51.  
  52. if isZ then
  53. -- They are AHEAD of the start location... Move Back.
  54. while z > start_z do
  55. turtle.back()
  56. end
  57. -- They are BEHIND the start location... Move Forward.
  58. while z < start_z do
  59. turtle.forward()
  60. end
  61. end
  62.  
  63. rednet.open("right")
  64. rednet.send(1, "The turtle has ran out of juice.")
  65. rednet.send(1, "Location: (" .. x .. "," .. y .. "," .. z .. ")")
  66. rednet.close("right")
  67.  
  68.  
  69. -- Helpful function to handle checking inventory code.
  70. isInventoryFull = function ()
  71. -- Search the inventory to see if all spaces are full...
  72. for i=1, 16 do
  73. if turtle.getItemCount(i) >= 64 then
  74. return true
  75. end
  76. end
  77. return false
  78. end
  79.  
  80. -- Helpful function to handle getting back to base.
  81. reachedBase = function ()
  82. return x == start_x and z == start_z
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement