Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x=0 --R/L
- y=0 --U/D
- z=0 --fwd/bck
- rot=0
- function rotate(direction)
- if rot==0 and direction == 3 then
- rot=4
- end
- if rot==3 and direction == 0 then
- rot=-1
- end
- while rot<direction do rot = rot+1 turtle.turnRight() end
- while rot>direction do rot = rot-1 turtle.turnLeft() end
- end
- function move(direction,dist)
- rotate(direction)
- while dist>0 do
- while not turtle.forward() do os.sleep(1) end
- dist = dist-1
- if rot == 0 then z = z+1 end
- if rot == 1 then x = x+1 end
- if rot == 2 then z = z-1 end
- if rot == 3 then x = x-1 end
- end
- end
- function moveV(dist)
- while dist>0 do
- if not turtle.up() then return false end
- dist = dist-1
- y = y+1
- end
- while dist<0 do
- if not turtle.down() then return false end
- dist = dist+1
- y = y-1
- end
- return true
- end
- function moveTo(tx,ty,tz)
- r=0
- if z<tz then r=0 else r=2 end
- d = math.abs(tz-z)
- move(r,d)
- if x<tx then r=1 else r=3 end
- d = math.abs(tx-x)
- move(r,d)
- moveV(ty-y)
- end
- function khuyam()
- --[[if turtle.detectUp() then
- turtle.digUp()
- moveV(1)
- khuyam()
- moveV(-1)
- end
- dirs = {0,1,3,2}
- for i=0,3 do
- rotate(dirs[i+1])
- if turtle.detect() then
- turtle.dig()
- move(dirs[i+1],1)
- khuyam()
- move(dirs[i+1]+2%4,1)
- end
- end
- --]]
- end
- rowLen=4
- colLen=2
- moveTo(0,0,3)
- turtle.select(1)
- for j=0,(colLen-1) do
- moveTo(-3*j-1,0,3)
- for i=0,(rowLen-1) do
- moveTo(-1-3*j,0,4+3*i)
- rotate(3)
- if not turtle.detect() then
- turtle.place()
- else
- repr = moveV(1)
- if turtle.detect() or repr==false then
- shell.run("chop")
- if repr then
- moveV(-1)
- end
- rotate(3)
- turtle.dig()
- turtle.place()
- else
- moveV(-1)
- end
- end
- end
- moveTo(-3*j-1,0,3)
- end
- moveTo(0,0,0)
- rotate(0)
- print("X: "..x)
- print("Y: "..y)
- print("Z: "..z)
- for i=2,16 do
- turtle.select(i)
- turtle.dropDown()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement