Advertisement
Guest User

Untitled

a guest
Mar 8th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1.  
  2.  
  3. function ping()
  4.     rednet.broadcast("Nano_Mining_Ping")
  5. end
  6.  
  7. function isFull()
  8.     local c=0
  9.     for i=4,16 do
  10.         if turtle.getItemCount(i)==0 then
  11.             c=c+1
  12.         end
  13.     end
  14.     if c<2 then
  15.         return true
  16.     else
  17.         return false
  18.     end
  19. end
  20.  
  21. function refuel()
  22.   for i=1,16 do
  23.         turtle.select(i)
  24.         turtle.refuel(64)
  25.     end
  26.  
  27. end
  28.  
  29. function dump()
  30.     turtle.select(1)
  31.     turtle.turnRight()
  32.     turtle.turnRight()
  33.     turtle.place()
  34.     for i=4,16 do
  35.         turtle.select(i)
  36.         turtle.drop()
  37.     end
  38.     turtle.dig()
  39.     turtle.turnLeft()
  40.     turtle.turnLeft()
  41. end
  42.  
  43. function empty()
  44.     if isFull() then dump() end
  45. end
  46.  
  47. function dig()
  48.     repeat turtle.dig() empty() ping() until not turtle.detect()
  49. end
  50.  
  51. function digUp()
  52.     repeat turtle.digUp() empty() ping() until not turtle.detectUp()
  53. end
  54.  
  55. function digDown()
  56.     repeat turtle.digDown() empty() ping() until not turtle.detectDown()
  57. end
  58.  
  59. function forward()
  60.     repeat
  61.     while turtle.getFuelLevel() == 0 do
  62.         print("waiting for fuel...")
  63.         refuel()
  64.     end
  65.     until turtle.forward()
  66.     ping()
  67. end
  68.  
  69. function up()
  70.     repeat until turtle.up()
  71. end
  72.  
  73. function down()
  74.     repeat until turtle.down()
  75. end
  76.  
  77. rednet.open("right")
  78. while true do
  79.     local a,b,c=rednet.receive()
  80.     print(a,b,c)
  81.     if a==69 or a==36 then
  82.         if b == "left" then turtle.turnLeft() end
  83.         if b == "right" then turtle.turnRight() end
  84.         if b == "forward" then forward() end
  85.         if b == "back" then turtle.back() end
  86.         if b == "up" then up() end
  87.         if b == "down" then down() end
  88.         if b == "dig" then dig() end
  89.         if b == "digUp" then digUp() end
  90.         if b == "digDown" then digDown() end
  91.     print(b)
  92.     end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement