SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local robot = require("robot") |
| 1 | + | --Created By RenKylo |
| 2 | - | robot.swing() |
| 2 | + | local robot = require("robot")
|
| 3 | - | inv = robot.inventorySize() |
| 3 | + | local component = require("component")
|
| 4 | - | while true do |
| 4 | + | local inv = component.inventory_controller |
| 5 | - | robot.select(1) |
| 5 | + | local inv_size = robot.inventorySize() |
| 6 | - | if robot.suck(64) then |
| 6 | + | --SETTINGS |
| 7 | - | size = robot.count(1) |
| 7 | + | local MIN_TOOL_CHARGE = 0.3 --Минимальный заряд бура |
| 8 | - | print(size) |
| 8 | + | local CHARGING_TIME = 10 --Время зарядки |
| 9 | - | robot.turnRight() |
| 9 | + | --FUNCTIONS |
| 10 | - | for i = 1, size do |
| 10 | + | function charging_tool() --Перезарядка бура |
| 11 | - | robot.place() |
| 11 | + | if robot.durability() < MIN_TOOL_CHARGE then |
| 12 | - | robot.swing() |
| 12 | + | robot.turnLeft() |
| 13 | inv.equip(1) | |
| 14 | - | robot.turnRight() |
| 14 | + | robot.drop(1) |
| 15 | - | for n = 1, inv do |
| 15 | + | os.sleep(CHARGING_TIME) |
| 16 | - | robot.select(n) |
| 16 | + | robot.suck(1) |
| 17 | - | robot.drop() |
| 17 | + | inv.equip(1) |
| 18 | robot.turnRight() | |
| 19 | - | robot.turnAround() |
| 19 | + | end |
| 20 | end | |
| 21 | - | os.sleep(0.2) |
| 21 | + | function robot_action() --Основные действия |
| 22 | robot.select(1) | |
| 23 | if robot.suck() then | |
| 24 | size = robot.count(1) | |
| 25 | robot.turnRight() | |
| 26 | for i = 1, size do | |
| 27 | robot.place() | |
| 28 | robot.swing() | |
| 29 | end | |
| 30 | robot.turnRight() | |
| 31 | for n = 1, inv_size do | |
| 32 | robot.select(n) | |
| 33 | if robot.drop() == false and n ~= 1 then | |
| 34 | break | |
| 35 | end | |
| 36 | end | |
| 37 | robot.turnAround() | |
| 38 | end | |
| 39 | os.sleep(0.2) | |
| 40 | end | |
| 41 | while true do | |
| 42 | if robot.durability() ~= nil then --Выполняется только если есть инструмент | |
| 43 | robot.select(1) | |
| 44 | charging_tool() | |
| 45 | robot_action() | |
| 46 | end | |
| 47 | end |