Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --утилита сбора урожая
- --поле 11х11
- --автор Taoshi
- --padtebin for dl dq5NNtEb
- robot=require('robot')
- --попытка движения вперёд
- forward=function()
- while robot.forward()~=true do print('ъпЪ!') os.sleep(1) end
- end
- --выгрузка инвентаря
- drop=function()
- local inv=robot.inventorySize()
- for f=1, inv do robot.select(f) robot.drop() end
- end
- --основное тело
- function doit(s,t)
- if s==nil then s=11 else
- if s%2==0 then s=s-1 end end
- if s==1 then s=3 end
- s=s-1
- if t==nil then t=19 end
- local z,x=s-1,s-1
- local turn,turn1='turnRight','turnLeft'
- forward()
- forward() robot.use()
- --обход левой верхней части поля
- for f=1,x do
- for g=1,z do
- forward() robot.use(0)
- end
- robot[turn]() forward() robot[turn]() robot.use()
- turn,turn1=turn1,turn
- end
- robot[turn]()
- --обход правого края в 2 клетки шириной
- turn,turn2='turnRight','turnLeft'
- for f=1,s do
- forward() robot.use(0) robot[turn]()
- forward() robot.use(0) robot[turn]()
- turn,turn2=turn2,turn
- end
- --обход возвратом нижнего ряда поля
- forward() robot.use(0) robot[turn]() robot[turn]()
- for f=1,s do
- forward() robot.use()
- end
- robot.turnLeft() forward() drop()
- robot.turnAround() os.sleep(t)
- end
- --самозацикливание. отключить для внешнего вызова
- while true do
- doit(11,19)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement