Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local com = require("component")
- local robot = require("robot")
- local term = require("term")
- local len, w, side
- local function place(len) --операция укладывания в длиннну
- for l = 1, len do
- robot.swingDown(0)
- robot.placeDown(0)
- robot.forward()
- end
- end
- local function work(len, side)
- turn = robot[(side == "right") and "turnRight" or "turnLeft"]
- place(len)
- turn()
- robot.forward()
- turn()
- robot.forward()
- end
- local function material() -- функция для проверки кол-ва материала, для того чтобы бот не встал посреди работы
- if robot.count() < l then
- robot.select(robot.select()+1)
- end
- end
- local function material()
- --summ = len * w
- -- for n = 1, 16 do
- -- функция для проверки кол-ва материала, для того чтобы бот не встал посреди работы
- if robot.count() < 1 then
- robot.select(robot.select()+1)
- end
- end
- print('Введите длину дороги: ')
- len = tonumber(term.read()) -- длина дороги
- print('Введите ширину дороги: ')
- w = tonumber(term.read()) -- ширина дороги
- print('Спасибо! Робот приступил к работе.')
- for i = 1, w do -- укладываем
- material()
- work(len, (i % 2 == 0) and "right" or "left")
- end
Advertisement
Add Comment
Please, Sign In to add comment