Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local computer = require('computer')
- local robot = require("robot")
- if require("component").isAvailable("generator")
- then
- generator=require("component").generator
- end
- local withg=(generator~=nil)
- function energy() return computer.energy()<((computer.maxEnergy()*70)/100) end
- function charg()
- print("Уровень энергии." ,computer.energy())
- if (energy()) then
- refuel()
- end
- if (computer.energy())<((computer.maxEnergy()*30)/100) then
- print("меньше 30 %")
- --while (computer.energy()) >=((computer.maxEnergy()*70)/100) do
- while energy() do
- for i=1, 10 do
- os.sleep(20)
- print("Ожидаю ",(10*i)..'%')
- end
- end
- end
- end
- function refuel() -- Заправка генератора
- for invfuel=1,16 do
- robot.select(invfuel)
- generator.insert(33)
- if generator.count() >= 32 then
- print("заправка зевершена")
- print("топлива в генераторе = "..generator.count())
- do break end
- end
- end
- end
- while true do
- robot.forward()
- robot.forward()
- robot.forward()
- robot.turnAround()
- robot.forward()
- robot.forward()
- robot.forward()
- charg()
- robot.turnAround()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement