Advertisement
LazyKernel

mineclient

Feb 24th, 2015
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.02 KB | None | 0 0
  1. local modem = peripheral.wrap("left")
  2. local allowMine = false
  3.  
  4. local length = 20
  5. local width = 20
  6. local right = true
  7.  
  8. local diggedDown = 0
  9. local diggedX = 0
  10. local diggedZ = 0
  11.  
  12. modem.open(3)
  13.  
  14. function getCommands()
  15. end
  16.  
  17. function goBackChest()
  18.   turtle.turnRight()
  19.   turtle.turnRight()
  20.  
  21.   for i=0, diggedX do
  22.     turtle.forward()
  23.   end
  24.  
  25.   if right then
  26.     turtle.turnLeft()
  27.   else
  28.     turtle.turnRight()
  29.   end
  30.  
  31.   for j=0, diggedZ do
  32.     turtle.forward()
  33.   end
  34.  
  35.   for y=0, diggedDown do
  36.     turtle.up()
  37.   end
  38.  
  39.   if turtle.detect() do
  40.     for z=1,16 do
  41.       turtle.select(z)
  42.       turtle.drop()
  43.     end
  44.   end
  45.  
  46.   turtle.turnRight()
  47.   turtle.turnRight()
  48.  
  49.   for y=0, diggedDown do
  50.     turtle.down()
  51.   end
  52.  
  53.   right = true
  54.   mine()
  55. end
  56.  
  57. function detectFullInv()
  58.   if turtle.getItemCount(16) ~= 0 then
  59.     goBackChest()
  60.   end
  61. end
  62.  
  63. function sendInfo()
  64. count = 0
  65.  for i=1,17 do
  66.    data = turtle.getItemDetail(i)
  67.    
  68.    if data then
  69.       count = count + data.count
  70.      end
  71.    end
  72.  end
  73.  
  74. modem.transmit(3, 1, count)
  75. detectFullInv()
  76. end
  77.  
  78. function mine()
  79.   if not allowMine then return 1 end
  80.  
  81.   turtle.digDown()
  82.   sendInfo()
  83.   os.sleep(1)
  84.   turtle.down()
  85.   diggedDown = diggedDown + 1
  86.   os.sleep(1)
  87.  
  88.   for i=1,length do
  89.     for j=1, width do
  90.       turtle.dig()
  91.       sendInfo()
  92.       os.sleep(1)
  93.       turtle.forward()
  94.       diggedX = diggedX + 1
  95.       os.sleep(1)
  96.     end
  97.    
  98.     diggedX = 0
  99.  
  100.     if right then
  101.       turtle.turnRight()
  102.       right = false
  103.       os.sleep(1)
  104.       turtle.dig()
  105.       sendInfo()
  106.       os.sleep(1)
  107.       turtle.forward()
  108.       diggedZ = diggedZ + 1
  109.       os.sleep(1)
  110.       turtle.turnRight()
  111.       os.sleep(1)
  112.     else
  113.       turtle.turnLeft()
  114.       right = true
  115.       os.sleep(1)
  116.       turtle.dig()
  117.       sendInfo()
  118.       os.sleep(1)
  119.       turtle.forward()
  120.       diggedZ = diggedZ + 1
  121.       os.sleep(1)
  122.       turtle.turnLeft()
  123.       os.sleep(1)
  124.     end
  125.   end
  126.  
  127.   diggedZ = 0
  128.  
  129.   mine()
  130. end
  131.  
  132. allowMine = true
  133. mine()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement