Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Created By RenKylo
- --Updated by tonupboy
- local robot = require("robot")
- local component = require("component")
- local inv = component.inventory_controller
- local inv_size = robot.inventorySize()
- --FUNCTIONS
- function robot_clear_bag()
- robot.suck(1) -- подобрать 1 слот из сундука
- os.sleep(1)
- robot.select(1) -- выбрать первый слот
- os.sleep(1)
- robot.turnRight() -- повернуть направо (лицом к пустому блоку)
- os.sleep(1)
- robot.use() -- пкм на слоте
- os.sleep(1)
- robot.suck(1) -- последовательно выложить все предметы из него в инвентарь
- os.sleep(1)
- robot.suck(2)
- os.sleep(1)
- robot.suck(3)
- os.sleep(1)
- robot.suck(4)
- os.sleep(1)
- robot.suck(5)
- os.sleep(1)
- robot.turnRight() -- повернуться направо
- os.sleep(1)
- -- вылоижть все из инвентаря в сундук
- os.sleep(1)
- for n = 1, inv_size do
- robot.select(n)
- if robot.drop() == false and n ~= 1 then
- break
- end
- end
- robot.turnAround()
- end
- 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
- function robot_setup() --Осмотреться и занять стартовое положение.
- for n = 1, 4 do
- block = robot.detect()
- print("Have block: ", block)
- if block == false then
- robot.turnLeft()
- break
- end
- robot.turnLeft()
- os.sleep(0.2)
- end
- end
- print("My level is: ")
- print(component.experience.level())
- robot_setup()
- robot_clear_bag()
- -- while true do
- -- if robot.durability() ~= nil then --Выполняется только если есть инструмент
- -- robot.select(1)
- -- charging_tool()
- -- robot_action()
- -- end
- -- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement