Advertisement
Celica45

CCMiningProgram

Mar 31st, 2022 (edited)
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.05 KB | None | 0 0
  1. -- data = turtle.inspect
  2. -- data.name is the block inspected, example, minecraft:chest
  3.  
  4. fuelEmpty = 200
  5. canLoop = "random"
  6.  
  7.  
  8.  
  9. function startUp()
  10.     print("startUp")
  11.     turtle.select(1)
  12.     turtle.suckDown()
  13.     turtle.refuel()
  14.     turtle.dropDown()
  15. end
  16.  
  17. function checkFuel()
  18.     print("Checking Fuel")
  19.     if turtle.getFuelLevel() < fuelEmpty then
  20.         turtle.turnLeft()
  21.         turtle.turnLeft()
  22.         a = 1
  23.         while a == 1 do
  24.             inspect = turtle.inspectDown()
  25.             if inspect == true then
  26.                 booldata, data = turtle.inspectDown()
  27.                 print(data.name)
  28.                 if data.name == "minecraft:chest" then
  29.                     turtle.turnLeft()
  30.                     turtle.turnLeft()
  31.                     for i = 1, 16 do
  32.                         turtle.select(i)
  33.                         turtle.dropDown()
  34.                     end
  35.                     a = 2
  36.                     return "x"
  37.                 else
  38.                     turtle.forward()
  39.                 end
  40.             else
  41.                 turtle.forward()
  42.             end
  43.         end
  44.     end
  45. end
  46.  
  47. function miningSet()
  48.     print("Mining Set")
  49.     for i = 1, 3 do
  50.         if turtle.detect() then
  51.             repeat
  52.                 turtle.dig()
  53.                 local success, digdig = turtle.detect()
  54.             until(success == false)
  55.         end
  56.         turtle.forward()
  57.         turtle.digDown()
  58.     end
  59. end
  60.  
  61.  
  62. function miningRight()
  63.     print("Mining Right")
  64.     turtle.turnRight()
  65.     if turtle.detect() then
  66.         for i = 1, 20 do
  67.                 if turtle.detect() then
  68.                     repeat
  69.                         turtle.dig()
  70.                         local success, digdig = turtle.detect()
  71.                     until(success == false)
  72.                 end
  73.                 turtle.forward()
  74.                 turtle.digDown()
  75.         end
  76.         turtle.turnLeft()
  77.         turtle.turnLeft()
  78.         for i = 1, 20 do
  79.             turtle.forward()
  80.         end
  81.         turtle.turnRight()
  82.     else
  83.         turtle.turnLeft()
  84.     end
  85. end
  86.  
  87.  
  88.  
  89. function miningLeft()
  90.     print("Mining Left")
  91.     turtle.turnLeft()
  92.     if turtle.detect() then
  93.         for i = 1, 20 do
  94.                 if turtle.detect() then
  95.                     repeat
  96.                         turtle.dig()
  97.                         local success, digdig = turtle.detect()
  98.                     until(success == false)
  99.                 end
  100.                 turtle.forward()
  101.                 turtle.digDown()
  102.         end
  103.         turtle.turnRight()
  104.         turtle.turnRight()
  105.         for i = 1, 20 do
  106.             turtle.forward()
  107.         end
  108.         turtle.turnLeft()
  109.     else
  110.         turtle.turnRight()
  111.     end
  112. end
  113.  
  114.  
  115. function checkInv()
  116.     if turtle.getItemCount(16) > 0 then
  117.         turtle.turnLeft()
  118.         turtle.turnLeft()
  119.         a = 1
  120.         while a == 1 do
  121.             inspect = turtle.inspectDown()
  122.             if inspect == true then
  123.                 booldata, data = turtle.inspectDown()
  124.                 print(data.name)
  125.                 if data.name == "minecraft:chest" then
  126.                     turtle.turnLeft()
  127.                     turtle.turnLeft()
  128.                     for i = 1, 16 do
  129.                         turtle.select(i)
  130.                         turtle.dropDown()
  131.                     end
  132.                     a = 2
  133.                     return "x"
  134.                 else
  135.                     turtle.forward()
  136.                 end
  137.             else
  138.                 turtle.forward()
  139.             end
  140.         end
  141.     end
  142. end
  143.  
  144.  
  145. --[[
  146. function checkInv()
  147.     print("Checking inventory")
  148.     turtle.select(16)
  149.     items = turtle.getItemCount
  150.     if items == 0 then
  151.         print("nice")
  152.     else
  153.         turtle.turnLeft()
  154.         turtle.turnLeft()
  155.         repeat
  156.             while true do
  157.                 turtle.forward()
  158.                 if turtle.inspectDown() == true then
  159.                     booldata, data = turtle.inspectDown()
  160.                     return
  161.                 end
  162.                 if turtle.inspectDown() == false then
  163.                     turtle.forward()
  164.                 end
  165.             end
  166.         until(string.find(data.name, "minecraft:chest"))
  167.         turtle.turnLeft()
  168.         turtle.turnLeft()
  169.         for i = 1, 16 do
  170.             turtle.select(i)
  171.             turtle.dropDown()
  172.             x = 2
  173.             return x
  174.         end
  175.     end
  176. end
  177. ]]--
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187. startUp()
  188. miningSet()
  189. while canLoop ~= "x" do
  190. miningLeft()
  191. miningRight()
  192. miningSet()
  193. canLoop = checkFuel()
  194. if canLoop ~= "x" then
  195.     canLoop = checkInv()
  196. end
  197. end
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205. --[[function miningRight()
  206.     turtle.turnRight()
  207.     local success, canDig = turtle.detect()
  208.     if success == true then
  209.         for i = 1, 20 do
  210.             repeat
  211.                 local success, canDig = turtle.detect()
  212.                 if success == true then
  213.                     turtle.dig()
  214.                 end
  215.             until(canDig == false)
  216.             turtle.forward()
  217.             turtle.digDown()
  218.         end
  219.     end
  220. end]]--
  221.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement