Advertisement
Roar337

tminer

Oct 5th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.36 KB | None | 0 0
  1. tPos = 0
  2. tLength = 250
  3.  
  4.  
  5. function turnAbout()
  6.   turtle.turnRight()
  7.   turtle.turnRight()
  8. end
  9.  
  10. function findOrigin()
  11.     turnAbout()
  12.     while tPos > 0 do
  13.       turtle.forward()
  14.       tPos = tPos - 1
  15.     end
  16.     turnAbout()
  17. end
  18.  
  19. function tryDig()
  20.   while turtle.inspect() do
  21.     if not turtle.dig() then
  22.       turtle.select(getItem("minecraft:cobblestone"))
  23.       turtle.place()
  24.       turtle.dig()
  25.       break
  26.     end
  27.     os.sleep(0.3)
  28.   end
  29. end
  30.  
  31. function getItem(item)
  32.   for i= 1, 16 do
  33.     local data = turtle.getItemDetail(i)
  34.     if data then
  35.       if data.name == item then
  36.         if turtle.getItemCount(i) > 0 then
  37.           return i
  38.         end
  39.       end
  40.     end
  41.   end
  42.   return 1
  43. end
  44.  
  45. function checkTunnel(digStage)
  46.  
  47.   turtle.select(getItem("minecraft:cobblestone"))
  48.  
  49.   if digStage == 0 then
  50.     if not turtle.detectDown() then
  51.       turtle.placeDown()
  52.     end
  53.     turtle.turnLeft()
  54.     if not turtle.detect() then
  55.       turtle.place()
  56.     end
  57.     turtle.turnRight()
  58.   elseif digStage == 1 then
  59.     if not turtle.detectUp() then
  60.       turtle.placeUp()
  61.     end
  62.     turtle.turnLeft()
  63.     if not turtle.detect() then
  64.     turtle.place()
  65.     end
  66.     turtle.turnRight()
  67.   elseif digStage == 2 then
  68.     if not turtle.detectUp() then
  69.       turtle.placeUp()
  70.     end
  71.     turtle.turnRight()
  72.     if not turtle.detect() then
  73.       turtle.place()
  74.     end
  75.     turtle.turnLeft()
  76.   elseif digStage == 3 then
  77.     turtle.turnRight()
  78.     if not turtle.detect() then
  79.       turtle.place()
  80.     end
  81.     turtle.turnLeft()
  82.     if not turtle.detectDown() then
  83.       turtle.placeDown()
  84.     end
  85.   end
  86.  end
  87.  
  88. function moveForward()
  89.     if not turtle.forward() then
  90.         tryDig()
  91.         turtle.forward()
  92.     end
  93. end
  94.  
  95. while tPos < tLength do
  96.  
  97.   if turtle.getFuelLevel() < 10 then
  98.     turtle.select(getItem("minecraft:coal"))
  99.     turtle.refuel()
  100.   end
  101.  
  102.   tryDig()
  103.   checkTunnel(0)
  104.   turtle.up()
  105.   tryDig()
  106.   checkTunnel(1)
  107.   turtle.turnRight()
  108.   moveForward()
  109.   turtle.turnLeft()
  110.   tryDig()
  111.   checkTunnel(2)
  112.   turtle.down()
  113.   tryDig()
  114.   checkTunnel(3)
  115.   turtle.turnLeft()
  116.   moveForward()
  117.   turtle.turnRight()
  118.   moveForward()
  119.   tPos = tPos + 1
  120.  
  121.   if tPos % 5 == 0 then
  122.     turtle.turnLeft()
  123.     tryDig()
  124.     turtle.select(getItem("minecraft:torch"))
  125.     turtle.place()
  126.     turtle.turnRight()
  127.   end
  128.  
  129. end
  130.  
  131. findOrigin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement