Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- терминатор для спавнера и лута. Проверка уровня робота
- -- слева зарядка, справа сундук
- local robot=require("robot")
- local sides = require("sides")
- local term = require("term")
- local comp = require("component")
- local event = require("event")
- local computer = require("computer")
- slots=16--количество слотов у робота?
- slotstocheck=2--выгрузка если заполнены последние N слотов
- function check() return robot.count(slots-(slotstocheck-1)) ~= 0 end -- полный?
- function energy() return computer.energy()<((computer.maxEnergy()*10)/100) end -- разрядился?
- function unload() -- выгрузка
- robot.turnRight()
- for inv=1,slots do
- robot.select(inv)
- robot.drop()
- end
- robot.select(1)
- robot.turnLeft()
- b = robot.level() -- узнать уровень
- print ("Уровень робота - ",(b))
- end
- function charg()
- if (energy()) then
- if computer.energy()<((computer.maxEnergy()*10)/100) then
- while computer.energy()<computer.maxEnergy()-20 do
- computer.beep(2000, 5)
- print(" Низкий уровень энергии." ,computer.energy())
- --robot.turnLeft()
- --robot.up()
- robot.useDown()
- --robot.down()
- print("Заряжаюсь")
- for i=1, 10 do
- os.sleep(4)
- end
- --robot.up()
- robot.useDown()
- --robot.down()
- --robot.turnRight()
- end
- end
- end
- end
- -------- Тело программы --------
- while true do
- -- проверка на сущность
- --repeat
- --a,t = robot.detect()
- --print (a,t)
- --until t == 'entity'
- for sw=1, 5 do
- robot.swing()
- robot.suck()
- end
- --
- if check() then unload() end
- charg()
- end
Add Comment
Please, Sign In to add comment