Advertisement
buffsovernexus

Untitled

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