BeastmodeJD

turtle_3x3

Sep 13th, 2021 (edited)
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.37 KB | None | 0 0
  1. local forbidItems = {
  2.     "lavastone",
  3.     "cobblestone",
  4.     "diorite",
  5.     "dirt",
  6.     "gravel",
  7.     "granite",
  8.     "andesite",
  9.     "scoria",
  10.     "marble"
  11. }
  12. function termReset()
  13.     term.clear()
  14.     term.setCursorPos(1,1)
  15. end
  16.  
  17. function refu()
  18.     turtle.select(1)
  19.     if (turtle.getItemCount() < 1) then
  20.         term.clear()
  21.         print("No fuel!")
  22.         return
  23.     end
  24.     if not (turtle.refuel()) then
  25.         term.clear()
  26.         print("Refuel Error!")
  27.         return
  28.     end
  29. end
  30.  
  31. function digRound(right)
  32.     while (turtle.detect()) do
  33.         turtle.dig()
  34.     end
  35.     if (right) then
  36.         turtle.turnRight()
  37.         turtle.forward()
  38.         turtle.turnLeft()
  39.     else
  40.         turtle.turnLeft()
  41.         turtle.forward()
  42.         turtle.turnRight()
  43.     end
  44. end
  45.  
  46. function digRoundSolo()
  47.     while (turtle.detect()) do
  48.         turtle.dig()
  49.     end
  50. end
  51.  
  52. local limit
  53. while not (tonumber(limit)) do
  54.     termReset()
  55.     print("How far would you like the turtle to dig in forward blocks? Must be number.");
  56.     limit = read()
  57. end
  58. limit = math.floor(tonumber(limit))
  59. local temp = 5
  60. termReset()
  61. print("Make sure turtle is in the bottom left of 3x3")
  62. while (temp > 0) do
  63.     sleep(1)
  64.     temp = temp - 1
  65. end
  66. termReset()
  67. print("running 3x3 mine for " .. limit .. " blocks")
  68. local path = 0
  69. -- refu()
  70. while (path < limit) do
  71.     -- if (turtle.getFuelLevel() < 1) then
  72.     --     refu()
  73.     -- end
  74.     turtle.up()
  75.     turtle.up()
  76.     digRound(true)
  77.     digRound(true)
  78.     digRoundSolo()
  79.     turtle.down()
  80.     digRound(false)
  81.     digRound(false)
  82.     digRoundSolo()
  83.     turtle.down()
  84.     digRound(true)
  85.     digRound(true)
  86.     digRoundSolo()
  87.     turtle.forward()
  88.     turtle.turnLeft()
  89.     turtle.forward()
  90.     turtle.forward()
  91.     turtle.turnRight()
  92.     local slot = 1
  93.     while (slot <= 16) do
  94.         turtle.select(slot)
  95.         local data = turtle.getItemDetail()
  96.         for i, v in pairs(forbidItems) do
  97.             if (data) then
  98.                 if string.find(data.name, v) then
  99.                     turtle.dropDown(turtle.getItemCount())
  100.                 end
  101.             end
  102.         end
  103.         slot = slot + 1
  104.     end
  105.     path = path + 1
  106. end
  107. termReset()
  108. print("Done! Returning Home")
  109. turtle.turnRight()
  110. turtle.turnRight()
  111. while (path > 0) do
  112.     turtle.forward()
  113.     path = path - 1
  114. end
  115. termReset()
  116. print("Done!")
Add Comment
Please, Sign In to add comment