Guest User

dig2

a guest
Nov 26th, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.73 KB | None | 0 0
  1. function fuel ()
  2.   if turtle.getFuelLevel() < 128 then
  3.     turtle.refuel(16)
  4.   end
  5. end
  6.  
  7. function dig ()
  8.   while turtle.detect() == true do
  9.     turtle.dig()
  10.     sleep(.5)
  11.   end
  12.   while turtle.detectUp() == true do
  13.     turtle.digUp()
  14.     sleep(.5)  
  15.   end
  16. end
  17.  
  18. function move ()
  19.   if turtle.detect() == false then
  20.     turtle.up()
  21.       if turtle.detect() == false then
  22.         turtle.down()
  23.         if turtle.detect() == false then
  24.           turtle.turnRight()
  25.           if turtle.detect() == true then
  26.             turtle.turnLeft()
  27.             mine()
  28.           elseif turtle.detect() == false then
  29.             turtle.turnLeft()
  30.             turtle.turnLeft()
  31.             if turtle.detect() == true then
  32.               turtle.turnRight()
  33.               mine()
  34.             elseif turtle.detect() == false then
  35.               turtle.turnRight()
  36.             end
  37.           end
  38.         elseif turtle.detect() == true then
  39.           mine()
  40.         end  
  41.       elseif turtle.detect() == true then
  42.         turtle.down()
  43.         mine()
  44.       end
  45.   elseif turtle.detect() == true then
  46.     mine()
  47.   end
  48.   turtle.forward()
  49.   if turtle.detectDown() == false then
  50.     turtle.select(3)
  51.     turtle.placeDown()
  52.     turtle.select(1)
  53.   end
  54. end
  55.  
  56. function mine  ()
  57.   fuel()
  58.   if full() == true then
  59.     return
  60.   end
  61.   dig()
  62.   turtle.turnRight()
  63.   dig()
  64.   turtle.turnLeft()
  65.   turtle.turnLeft()
  66.   dig()
  67.   turtle.turnRight()
  68.   turtle.up()
  69.   dig()
  70.   turtle.turnRight()
  71.   dig()
  72.   turtle.turnLeft()
  73.   turtle.turnLeft()
  74.   dig()
  75.   turtle.turnRight()
  76.   turtle.down()
  77.   dig()
  78.   turtle.turnLeft()
  79.   dig()
  80.   turtle.turnRight()
  81.   turtle.turnRight()
  82.   dig()
  83.   turtle.turnLeft()
  84. end
  85. function full ()
  86.   if turtle.getItemCount(15) > 0 then
  87.     turtle.turnLeft()
  88.     turtle.turnLeft()
  89.     turtle.up()
  90.     turtle.select(16)
  91.     drop()
  92.   end  
  93. end
  94.  
  95. function drop ()
  96.     while turtle.compareDown(16) == false do
  97.       turtle.forward()
  98.     end  
  99.     for y = 4, 15, 1 do
  100.       turtle.select(y)
  101.       turtle.dropDown()
  102.     end
  103.     turtle.turnLeft()
  104.     turtle.turnLeft()
  105.     turtle.forward()
  106.     turtle.down()
  107.     turtle.select(1)
  108.     while x < 3 do
  109.       x = x + 1
  110.       print(x)
  111.       on()
  112.     end
  113.     print("Press any key to continue")
  114.     local event, key = os.pullEvent("key")
  115.       print("Rebooting")
  116.       os.reboot()
  117. end    
  118.    
  119. function torch ()
  120.   for x = 0, 8, 1 do
  121.     move()      
  122.   end
  123.   if full() == true then
  124.     return
  125.   end
  126.   turtle.turnRight()
  127.   turtle.turnRight()
  128.   turtle.select(2)
  129.   turtle.place()
  130.   turtle.select(1)
  131.   turtle.turnRight()
  132.   turtle.turnRight()
  133. end  
  134.  
  135. function on ()
  136.   while true do
  137.     torch()
  138.     full()
  139.     sleep(3)
  140.   end
  141. end
  142.  
  143. x = 0
  144. while true do
  145.   on()
  146. end
Add Comment
Please, Sign In to add comment