Bonkie

Computercraft Turtle Mining Program

Apr 2nd, 2013
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. function emptyInv()
  2.   for i=1,16 do
  3.     turtle.select(i)
  4.     e=64
  5.     while e ~= 0 do
  6.       turtle.dropDown()
  7.       e = turtle.getItemCount(i)
  8.       print("Items in slot "..i..":"..e)
  9.     end
  10.   end
  11. end
  12.  
  13. function wellPickup()
  14.   turtle.select(1)
  15.   e=64
  16.   while e ~= 0 do
  17.     turtle.dropDown()
  18.     sleep(2)
  19.     e = turtle.getItemCount(1)
  20.     print("Items in slot 1:"..e)
  21.   end
  22.   turtle.dig()
  23.   local m = peripheral.wrap("right")
  24.   m.transmit(2,2,"ready")
  25. end
  26.  
  27. function waitForMove()
  28.   print("Waiting for response if frame move finished")
  29.   x = os.clock()
  30.   local m = peripheral.wrap("right")
  31.   m.open(3)
  32.   x=0
  33.   while x==0 do
  34.     local event,modemside,senderchannel,replychannel,message,senderdistance = os.pullEvent("modem_message")
  35.     if (senderchannel==3) then
  36.       x = message
  37.       print("Frame move done")
  38.       y = os.clock()-x
  39.       print("seconds: "..y)
  40.     else
  41.       x = 0
  42.     end
  43.   end
  44. end
  45.  
  46. function wellPlace()
  47.   turtle.select(1)
  48.   turtle.place()
  49.   sleep(1)
  50. end
  51.  
  52. for i=1,32 do
  53.   if turtle.detect()==false then
  54.     wellPlace()
  55.   end
  56.   emptyInv()
  57.   wellPickup()
  58.   waitForMove()
  59.   wellPlace()
  60.   if (i==32) then
  61.     print("laatste run")
  62.     exit()
  63.   else
  64.     print("sleep...")
  65.     sleep(10)
  66.   end
  67. end
Advertisement
Add Comment
Please, Sign In to add comment