Advertisement
Guest User

dig

a guest
Mar 28th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. funtion digger()
  2.   senderID, message, distance = rednet.receive ()
  3.   if senderID == mccID then
  4.     command = string.sub (message, 1, 3)
  5.     waitTime = tonumber (string.sub (message, -2))
  6.     if command == "dig" then
  7.       print ("Message received to dig.")
  8.       turtle.select (1)
  9.       turtle.place ()
  10.       os.sleep (waitTime)
  11.       drop()
  12.       turtle.select (1)
  13.       turtle.dig ()
  14.       rednet.send (mccID, "complete")
  15.       print ("Digging complete.")
  16.     else
  17.       print (senderID.."said '"..message.."'")
  18.     end
  19.   else
  20.     print (senderID.." said'"..message"'")
  21.   end
  22. end
  23.  
  24. function drop()
  25.   empty - false
  26.   while not empty do
  27.     for i = 1, 16 do
  28.       turtle.select (i)
  29.       turtle.dropDown ()
  30.     end
  31.     empty = true
  32.     for i = 1, 16 do
  33.       if turtle.getItemCount(i) > 0 then
  34.         empty = false
  35.       end
  36.     end
  37.   end
  38. end
  39.  
  40. mccId = 45
  41. rednet.open ("right)
  42. while true do
  43.  digger()
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement