espertus

Mining program created with Blockly Lua

Oct 31st, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. function explore()
  2.   for count = 1, 4 do
  3.     if turtle.detect() and interesting_block_ahead() then
  4.       while turtle.detect() do
  5.         if not turtle.dig() then
  6.           return
  7.         end
  8.         sleep(0.8)
  9.       end
  10.       if turtle.forward() then
  11.         explore()
  12.         turtle.back()
  13.       end
  14.     end
  15.     turtle.turnRight()
  16.   end
  17. end
  18.  
  19. function mine(max_depth)
  20.   depth = 0
  21.   for count2 = 1, math.floor(max_depth) do
  22.     if turtle.detectDown() and not turtle.digDown() then
  23.       break
  24.     end
  25.     depth = depth + 1
  26.     turtle.down()
  27.     explore()
  28.   end
  29.   for count3 = 1, math.floor(depth) do
  30.     turtle.up()
  31.   end
  32. end
  33.  
  34. function interesting_block_ahead()
  35.   for _, k in ipairs(boring_slots) do
  36.     turtle.select(k)
  37.     if turtle.compare() then
  38.       return false
  39.     end
  40.   end
  41.   return true
  42. end
  43.  
  44.  
  45. boring_slots = ({12, 13, 14, 15, 16})
  46.  
  47. mine(10)
Advertisement
Add Comment
Please, Sign In to add comment