Will11690

Miner1

Apr 9th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. rednet.open("left")
  2.  
  3. local trustedID = 26
  4. local ID = 22
  5.  
  6. function checkCoal()
  7.  
  8.   turtle.select(1)
  9.   turtle.getItemCount()
  10.  
  11.     if turtle.getItemCount() <= 4 then
  12.  
  13.         turtle.select(16)
  14.         turtle.placeUp()
  15.         turtle.select(1)
  16.         turtle.suckUp(60)
  17.         turtle.select(16)
  18.         turtle.digUp()
  19.         turtle.select(1)
  20.    
  21.     end
  22.  
  23. end
  24.  
  25. function checkFuel()
  26.  
  27.   turtle.getFuelLevel()
  28.  
  29.   if turtle.getFuelLevel() <= 10 then
  30.  
  31.     turtle.select(1)
  32.     turtle.refuel(1)
  33.    
  34.   end
  35.  
  36. end
  37.  
  38. function beginMining()
  39.  
  40.   turtle.select(2)
  41.   turtle.forward(1)
  42.   turtle.place()
  43.   turtle.select(3)
  44.   turtle.up(1)
  45.   turtle.place()
  46.   turtle.select(4)
  47.   turtle.back(1)
  48.   turtle.down(1)
  49.   turtle.place()
  50.   sleep(40)
  51.  
  52. end
  53.  
  54. function endMining()
  55.  
  56.   turtle.select(4)
  57.   turtle.dig()
  58.   turtle.select(2)
  59.   turtle.forward(1)
  60.   turtle.dig()
  61.   turtle.select(3)
  62.   turtle.up(1)
  63.   turtle.dig()
  64.   turtle.down()
  65.  
  66. end
  67.  
  68. function rednetControl()
  69.  
  70.  trustedID, message = rednet.receive()
  71.  
  72.  if message == "Identify" then
  73.  
  74.    print("Identifing")
  75.    rednet.send(trustedID, "Miner1")
  76.    print("Identified")
  77.    
  78.    trustedID, message = rednet.receive()
  79.  
  80.     if message == "Check" then
  81.  
  82.      print("Checking")
  83.      checkCoal()
  84.      checkFuel()
  85.      rednet.send(trustedID, "Checked")
  86.      print("Checked")
  87.      
  88.       trustedID, message = rednet.receive()
  89.  
  90.       if message == "Mine" then
  91.  
  92.         print("Mining")
  93.         beginMining()
  94.         endMining()
  95.         print("Mining Complete")
  96.         rednet.send(trustedID, "Complete")
  97.    
  98.       end
  99.  
  100.     end
  101.  
  102.   end
  103.  
  104. end
  105.  
  106. rednetControl()
Add Comment
Please, Sign In to add comment