libraryaddict

Untitled

May 1st, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. ID = 14
  2. id1 = 0
  3. rednet.open("right")
  4. shell.run("clear")
  5. print("M to mine")
  6. function compare()
  7.   for n=1,3 do
  8.     turtle.select(n)
  9.     if turtle.compare() then
  10.       rednet.broadcast("Prepare your anus")
  11.       return true
  12.     end
  13.   end
  14. end
  15.    
  16. function mine()
  17.   for n=1,2 do
  18.     if not compare() then
  19.       turtle.dig()
  20.       turtle.up()
  21.     else
  22.       prepare()
  23.     end
  24.   end
  25.   if not compare() then
  26.     turtle.dig()
  27.   else
  28.     prepare()
  29.   end
  30.   turtle.down()
  31.   turtle.down()
  32. end
  33. function prepare()
  34.   turtle.down()
  35.   turtle.down()
  36.   turtle.up()
  37.   turtle.up()
  38.   turtle.back()
  39.   turtle.back()
  40.   print("Press o when you are done")
  41. end
  42. Times = 0
  43. while true do
  44.   event, id, msg = os.pullEvent()
  45.   if id == ID or id1 == ID then
  46.     if msg == "Prepare your anus" then
  47.       print("Something in front of me")
  48.       prepare()
  49.     elseif msg == "done" then
  50.       Times = Times+1
  51.       if Times == 2 then
  52.         rednet.broadcast("forwards!")
  53.         print("Forwards!")
  54.         Times = 0
  55.         turtle.select(4)
  56.         turtle.placeDown()
  57.         if not turtle.forward() then
  58.           rednet.broadcast("I cannot")
  59.           print("Cant go forwards!")
  60.           turtle.back()
  61.           mine()
  62.         end
  63.       end
  64.     end
  65.   elseif event == "char" and id == "o" then
  66.     print("Its over! Back to mining!")
  67.     rednet.broadcast("itsover")
  68.     turtle.forward()
  69.     turtle.forward()
  70.     turtle.down()
  71.     turtle.down()
  72.     mine()
  73.   elseif event == "char" and id == "m" then
  74.     rednet.broadcast("mine")
  75.     print("Mine!")
  76.     mine()
  77.   end
  78. end
Advertisement
Add Comment
Please, Sign In to add comment