Advertisement
ivan52

b1

Apr 12th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.72 KB | None | 0 0
  1. function viravn()
  2. h1=1
  3.   turtle.up()
  4.   while turtle.detectUp()==true do
  5.     turtle.digUp()
  6.     turtle.up()
  7.     h1=h1+1
  8.   end
  9.   while h1>0 do
  10.     turtle.down()
  11.     h1=h1-1
  12.   end  
  13. end
  14. local MIN_FUEL = 300
  15. local AUTO_REFUEL = true
  16.  
  17. local function  refuel()
  18.         for i = 1, 16 do
  19.         turtle.select(i)
  20.                 turtle.refuel()
  21.         end
  22.         turtle.select(1)              
  23. end
  24.  
  25. local function clearDrop()
  26.         if AUTO_REFUEL and turtle.getFuelLevel() < MIN_FUEL then refuel() end
  27.     for slot = 1, 16 do
  28.         turtle.select(slot)
  29.         turtle.dropDown()
  30.     end
  31. end
  32.  
  33. function  forward()
  34.                 while not turtle.forward() do
  35.                         turtle.attack()
  36.                         sleep(1)
  37.                 end
  38. end
  39. local function  forward1()
  40.         while not turtle.forward() do
  41.                 if not turtle.dig() then
  42.                 turtle.attackUp()
  43.                 sleep(1)
  44.             end
  45.     end
  46.    
  47. end
  48. local function  up()
  49.         while not turtle.up() do
  50.                 if not turtle.digUp() then
  51.                 turtle.attackUp()
  52.                 sleep(1)
  53.             end
  54.     end
  55.     h = h+1
  56. end
  57.  
  58. local function  down()
  59.         while not turtle.down() do
  60.                 if not turtle.digDown() then
  61.                 turtle.attackDown()
  62.                 sleep(1)
  63.             end
  64.     end
  65.     h = h-1
  66. end
  67.  
  68. local function  left()
  69.         turtle.turnLeft()
  70. end
  71.  
  72. local function  right()
  73.         turtle.turnRight()
  74. end
  75.  
  76. local function around()
  77.         right()
  78.         right()
  79. end
  80.  
  81. local function  returnWall()
  82.     while true do
  83.     local state, typeblock = turtle.inspect()  
  84.             if typeblock.name ~= 'minecraft:cobblestone'  then
  85.                 if (typeblock.name == 'ComputerCraft:CC-TurtleExpanded') or (typeblock.name == 'ComputerCraft:CC-Turtle') then
  86.                 sleep(1)
  87.                 else
  88.                  forward1()
  89.                 end
  90.             else
  91.                 right()
  92.                 break
  93.             end
  94.     end
  95. end
  96.  
  97. local function  returnMatka()
  98.         while true do
  99.                 forward()
  100.         end
  101. end
  102.  
  103. local function digHole()
  104.                 h = 0
  105.                 while true do
  106.                         local state, typeblock = turtle.inspectDown()
  107.                 if typeblock.name ~= 'minecraft:bedrock' then
  108.                                 down()
  109.                 turtle.dig()
  110.             else
  111.                 break                              
  112.             end
  113.         end                
  114. end
  115.  
  116. local function returnSurface()
  117.         while h~=0 do
  118.                 turtle.dig()
  119.                 up()      
  120.         end    
  121. end
  122.  
  123. local function  main()
  124.         os.setComputerLabel("BABY-"..os.getComputerID())
  125.         term.clear()
  126.         term.setCursorPos(1,1)
  127.         print('Fuel level: ', turtle.getFuelLevel())
  128.         print('Easy dig running!')
  129.         peripheral.call('left','turnOn')
  130.         peripheral.call('right','turnOn')
  131.         refuel()
  132.                 if turtle.getFuelLevel() < MIN_FUEL then
  133.                         error('Fatal ERROR, put fuel in any slot end PRESS Ctrl+R!')
  134.                 end
  135.         digHole()
  136.         around()
  137.         for i = 1, 4 do up()  end
  138.         while turtle.detect() do turtle.dig() end
  139.         forward()
  140.         while true do
  141.                         local state, typeblock = turtle.inspectDown()
  142.                 if typeblock.name ~= 'minecraft:bedrock' then
  143.                                 down()
  144.             else
  145.                 break                              
  146.             end
  147.         end        
  148.         returnSurface()
  149.         around()
  150.         returnWall()
  151.         clearDrop()
  152.         returnMatka()
  153. end
  154.  
  155. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement