Advertisement
Rusettsten

StripMine

Nov 30th, 2020 (edited)
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. --Advanced StripMine API for DanetOS3
  2. local tArgs = { ... }
  3. if #tArgs == nil then
  4.     print("Strip Mine ERROR: Incorrect Usage. StripMine <direction> <direction2> <offset> <distance>")
  5.     return
  6. end
  7.  
  8. function dropoffItems()
  9.     turtle.select(1)
  10.     if turtle.refuel(0) then --Skip the fuel if there is any
  11.         print("SUCCESS! Fuel Detected. Not Dropping.")
  12.     else
  13.         turtle.dropDown()
  14.     end
  15.    
  16.     for x=3,16 do --Drop items into chest below
  17.         turtle.select(x)
  18.         turtle.dropDown()
  19.     end
  20. end
  21.  
  22.  
  23. --MAIN INSTRUCTIONS GO HERE
  24.  
  25. cardinalDirection = tArgs[1]
  26. cardinalDirection2 = tArgs[2]
  27. offset = tonumber(tArgs[3])
  28. distance = tonumber(tArgs[4])
  29.  
  30. local fuelNeeded = offset * 2
  31. shell.run("TurtleRefuel " .. offset) --Refuel for the movement trip
  32.  
  33. if cardinalDirection == "north" or cardinalDirection == "south" then
  34.     turtle.up()
  35.     shell.run("TurnToFace " .. cardinalDirection) --Turn the turtle to face the direction it's going to be going
  36. else
  37.     print("Strip Mine ERROR! Must define a valid direction. Please use north or south.")
  38.     os.wait(10)
  39.     shell.run("reboot")
  40. end
  41.  
  42. while not turtle.forward() do sleep(0.5) end --Go one forward
  43.  
  44. if cardinalDirection2 == "east" or cardinalDirection2 == "west" then
  45.     shell.run("TurnToFace " .. cardinalDirection2) --Turn to face the hallway direction to go in
  46.    
  47.     for x=0,offset do --Go that many blocks down the hallway
  48.         while not turtle.forward() do sleep(0.5) end
  49.     end
  50. else
  51.     print("Strip Mine ERROR! Must define a valid 2nd direction. Please use east or west.")
  52.     os.wait(10)
  53.     shell.run("reboot")
  54. end
  55.  
  56. --DIG TIME!
  57.  
  58. shell.run("TurnToFace " .. cardinalDirection) --Turn to face the first cardinal direction.
  59. shell.run("BasicDig " .. distance .. " 4 true")
  60.  
  61. --TIME TO GO BACK!
  62.  
  63. if cardinalDirection2 == "east" then
  64.     shell.run("TurnToFace west")
  65. else
  66.     shell.run("TurnToFace east")
  67. end
  68.  
  69. for x=0,offset do --Go that many blocks down the hallway
  70.     while not turtle.forward() do sleep(0.5) end
  71. end
  72.  
  73. if cardinalDirection == "north" then
  74.     shell.run("TurnToFace south")
  75. else
  76.     shell.run("TurnToFace north")
  77. end
  78.  
  79. while not turtle.forward() do sleep(0.5) end --Go one forward
  80.  
  81. shell.run("TurnToFace north") --Always end up turning north
  82. turtle.down()
  83. dropoffItems()
  84. print("SUCCESS! StripMine Complete.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement