Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local a = {}
- local args = {...}
- local counter = 4
- local numbering = 5
- local posX = 0
- local posY = 0
- local posZ = 0
- posX, posY, posZ = gps.locate(5)
- local startX = posX
- local startY = posY
- local startZ = posZ
- local direction = 0
- local inventory = 1
- function a.orient()
- turtle.forward()
- posX, posY, posZ = gps.locate(5)
- if posX-startX > 0 then
- direction = 0
- end
- if posZ-startZ > 0 then
- direction = 1
- end
- if posX-startX < 0 then
- direction = 2
- end
- if posX-startX < 0 then
- direction = 3
- end
- end
- function a.moveTo(targetX,targetY,targetZ)
- posX, posY, posZ = gps.locate(5)
- while posY > targetY do
- turtle.down()
- end
- while posY < targetY do
- turtle.up()
- end
- if posX > targetX then
- a.rotateTo(2)
- end
- if posX < targetX then
- a.rotateTo(0)
- end
- while posX ~= targetX do
- turtle.forward()
- end
- if posZ > targetZ then
- a.rotateTo(3)
- end
- if posZ < targetZ then
- a.rotateTo(1)
- end
- while posZ ~= targetZ do
- turtle.forward()
- end
- end
- function a.rotateTo(targetD)
- while direction ~= targetD
- if direction > 3 then
- direction = 0
- end
- if direction < 0 then
- direction = 3
- end
- if direction < targetD then
- direction = direction + 1
- turtle.turnRight()
- end
- if direction > targetD then
- direction = direction - 1
- turtle.turnLeft()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement