Advertisement
Te-ki

CC BlockMiner

Feb 28th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.80 KB | None | 0 0
  1. --ComputerCraft BlockMiner by Teki
  2.  
  3. local details
  4. local blockDetected, blockDetails
  5.  
  6. local function getfirstFreeSlot(bDetails)
  7.     for i =1,16 do
  8.         details = turtle.getItemDetail(i)
  9.         if details ~= nil and turtle.getItemSpace(i) >= 1 and details.name == bDetails.name then
  10.             return i
  11.         end
  12.     end
  13.     for i =1,16 do
  14.         details = turtle.getItemDetail(i)
  15.         if details == nil then
  16.             return i
  17.         end
  18.     end
  19.     return 0
  20. end
  21.  
  22. while true do
  23.     blockDetected, blockDetails = turtle.inspect()
  24.     firstFreeSlot = getfirstFreeSlot(blockDetails)
  25.     if firstFreeSlot ~= 0 then
  26.         turtle.select(firstFreeSlot)
  27.         if blockDetails.name == "minecraft:flowing_lava" then
  28.             redstone.setOutput("top", true)
  29.         else
  30.             redstone.setOutput("top", false)
  31.             if turtle.detect() then
  32.                 turtle.dig()
  33.             end
  34.         end
  35.     end
  36.     sleep(0)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement