Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local x,y,z,dir
- function loc(txt)
- x,y,z = gps.locate(2, false)
- if x == nil then
- print("Blad GPS")
- else
- if txt then
- print("Pos: " .. x .. ", " .. y .. ", " .. z)
- end
- end
- end
- function turn(ctdir)
- while dir ~= ctdir do
- print(dir)
- turtle.turnRight()
- dir = dir + 1
- if dir == 4 then dir = 0 end
- end
- end
- write("Cur: ")
- loc(true)
- write("Cur: Dir: ")
- sx = x
- sy = y
- sz = z
- place = true
- if turtle.forward() then
- place = false
- else
- turtle.dig()
- turtle.forward()
- end
- loc(false)
- if z == (sz+1) then dir = 0 end
- if x == (sx-1) then dir = 1 end
- if z == (sz-1) then dir = 2 end
- if x == (sx+1) then dir = 3 end
- turtle.back()
- if place then
- turtle.place()
- end
- print(dir)
- write("Tgt: Pos: ")
- local tArgs = { ... }
- tx = tonumber(tArgs[1])
- ty = tonumber(tArgs[2])
- tz = tonumber(tArgs[3])
- tdir = dir
- print(tx .. ", " .. ty .. ", " .. tz)
- print(" ")
- write("Tgt: Dir: ")
- print(tdir)
- while y ~= ty do
- if y<ty then
- if turtle.up() then
- else
- turtle.digUp()
- turtle.up()
- turtle.placeDown()
- end
- end
- if y>ty then
- if turtle.down() then
- else
- turtle.digDown()
- turtle.down()
- turtle.placeUp()
- end
- end
- loc(true)
- end
- if x>tx then ctdir = 1 end
- if x<tx then ctdir = 3 end
- turn(ctdir)
- print(ctdir)
- while x ~= tx do
- if turtle.forward() then
- else
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- end
- loc(true)
- end
- if z>tz then ctdir = 2 end
- if z<tz then ctdir = 0 end
- turn(ctdir)
- print(ctdir)
- while z ~= tz do
- if turtle.forward() then
- else
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.turnRight()
- turtle.place()
- turtle.turnRight()
- turtle.turnRight()
- end
- loc(true)
- end
- turn(tdir)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement