Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Created By RenKylo
- local robot = require("robot")
- local component = require("component")
- local inv = component.inventory_controller
- local inv_size = robot.inventorySize()
- --SETTINGS
- local MIN_TOOL_CHARGE = 0.3 --Минимальный заряд бура
- local CHARGING_TIME = 10 --Время зарядки
- --FUNCTIONS
- function charging_tool() --Перезарядка бура
- if robot.durability() < MIN_TOOL_CHARGE then
- robot.turnLeft()
- inv.equip(1)
- robot.drop(1)
- os.sleep(CHARGING_TIME)
- robot.suck(1)
- inv.equip(1)
- robot.turnRight()
- end
- end
- function robot_action() --Основные действия
- robot.select(1)
- if robot.suck() then
- size = robot.count(1)
- robot.turnRight()
- for i = 1, size do
- robot.place()
- robot.swing()
- end
- robot.turnRight()
- for n = 1, inv_size do
- robot.select(n)
- if robot.drop() == false and n ~= 1 then
- break
- end
- end
- robot.turnAround()
- end
- os.sleep(0.2)
- end
- while true do
- if robot.durability() ~= nil then --Выполняется только если есть инструмент
- robot.select(1)
- charging_tool()
- robot_action()
- end
- end
Add Comment
Please, Sign In to add comment