Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local com = require("component")
- local bot = require("robot")
- local term = require("term")
- function digandplace() --операция укладывания
- for i = 1, l do
- bot.swingDown(0)
- bot.placeDown(0)
- bot.forward()
- end
- end
- function work_l() -- для четных итераций
- digandplace()
- bot.turnLeft()
- bot.forward()
- bot.turnLeft()
- bot.forward()
- end
- function work_r() -- для нечетных итераций
- digandplace()
- bot.turnRight()
- bot.forward()
- bot.turnRight()
- bot.forward()
- end
- function check_material() -- функция для проверки кол-ва материала, для того чтобы бот не встал посреди работы
- if bot.count() < l then
- bot.select(bot.select()+1)
- end
- end
- print('Введите длину дороги: ')
- l = tonumber(term.read()) -- длина дороги
- print('Введите ширину дороги: ')
- w = tonumber(term.read()) -- ширина дороги
- print('Спасибо! Робот приступил к работе.')
- for i = 1, w do -- укладываем
- check_material()
- if i % 2 == 0 then -- делаем проверку, чтобы робот поворачивал в нужном направлении
- work_r()
- else
- work_l()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement