Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --quarry
- --копает область х, z, y размером
- --в положительной оси координат
- --вперёд z, вправо х, вниз у блоков
- function quarry(x,z,y)
- local x, z, y=x, z, y
- local robot=require("component.robot")
- local detect=require("robot.detect")
- local swing=require("robot.swing")
- local forward=require("robot.forward")
- local mSide=reqiure("robot.side")
- local dig = --вперёд вниз вверх
- function(side)
- if detect[side]
- then swing[side]
- end
- return robot[side]
- end
- function trawel(i,side)
- for f=2,i do mSide(side) end
- return true end
- local up={} --возврат по координатам
- up[0]=function()
- trawel(y, "up")
- end
- up[1]=function()
- trawel(y, "up")
- robot.turn("right")
- trawel(z, "forward")
- robot.turnAround()
- end
- up[3]=function()
- trawel(y, "up")
- trawel(x, "forward")
- robot.turn(right)
- end
- up[2]=function()
- trawel(z, "forward")
- robot.turn("right")
- up[3]()
- end
- local turnSide="turnRight"
- local nextTurn="turnLeft"
- for cy=2,y do --основной цикл копки
- dig("down")
- for cx=2,x do
- for cz=2,z do
- dig("forward")
- end --cz loop
- robot[turnSide]()
- if cx<x then
- dig("forward")
- robot.forward()
- else if x%2==0 robot.turnLeft() end
- end
- robot[turnSide]()
- turnSide, nextTurn=nextTurn, turnSide
- end --cx loop
- robot[nextTurn]()
- end --cy loop
- --вычисляем в каком углу робот:
- --1=z 2=zx 3=x 4=0 и возвращаемся
- up[((3+x%2)*y)%4]
- end --возврат из функции карьер
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement