Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Эффективный робот кровельщик
- --(c) SergOmarov, 2015
- local robotc=require("component").robot
- local robot=require("robot")
- local robot_back=robot.back
- local robot_forward=robot.forward
- local curslot=robot.select(1)
- local function getSize()--функция измерения размером
- local h=0
- local w=0
- local forward=true
- local back=true
- local function a(functionA)
- repeat
- back=robot_back()
- until back==nil
- repeat
- forward=robot_forward()
- functionA()
- until forward==nil
- end
- a(function()w=w+1 end)
- robot.turnRight()
- a(function()h=h+1 end)
- return w,h
- end
- local W,H=getSize()
- H=H-1
- local function build()
- local turn=true
- for i=1,W do
- for j=1,H do
- robot_back()
- robot.place()
- end
- if robot.count(curslot) == 0 then curslot = curslot + 1 end
- if robot.count(curslot) == 0 then print("Кончились блоки, Хозяин, закинь") end
- robot.select(curslot)
- if(i%2==1)then
- turn=false
- else
- turn=true
- end
- robotc.turn(turn)
- robot_back()
- robot.place()
- robotc.turn(turn)
- end
- end
- build()
- robot.up()
- robot.place(0)
- ::r::
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement