StreamerYT

miner

Sep 12th, 2020 (edited)
1,209
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local computer = require("computer")
  2. local component = require("component")
  3. local robot = require("robot")
  4. local inv = component.inventory_controller
  5. local gpu = component.gpu
  6.  
  7. local blocks = 0
  8.  
  9. gpu.fill(1,1,50,16," ")
  10.  
  11. function Test()
  12.     local item = robot.durability()
  13.     if item <= 0.1 then
  14.         home()
  15.         return 0
  16.     elseif computer.energy() <= 1000 then
  17.         home()
  18.         return 0
  19.     end
  20.     robot.select(robot.inventorySize())
  21.     if robot.count() >= 1 then
  22.         home()
  23.         return 0
  24.     end
  25.     return 1
  26. end
  27.  
  28. function home()
  29.     robot.turnAround()
  30.     for i = 0, blocks do
  31.         robot.swing()
  32.         robot.forward()
  33.     end
  34.     blocks = 0
  35.     robot.turnLeft()
  36.         for i = 1,robot.inventorySize() do
  37.             robot.select(i)
  38.             robot.drop(robot.count(i))
  39.         end
  40.     robot.turnRight()
  41.     inv.equip()
  42.     robot.drop(1)
  43.     os.sleep(10)
  44.     robot.suck()
  45.     inv.equip()
  46.     robot.turnAround()
  47.     robot.forward()
  48.     os.sleep(10)
  49.     robot.back()
  50.    
  51. end
  52.  
  53. while true do
  54.     local etest = Test()
  55.     if etest then
  56.         robot.swing()
  57.         local move = robot.forward()
  58.         if move then
  59.             blocks=blocks+1
  60.         end
  61.     end
  62. end
RAW Paste Data