Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local awal = vector.new(gps.locate())
- local sideawal ="east"
- local side = "east"
- local array = {"east","south","west","north"} --turn right
- ------------------------------------ FUNCTION GPS ------------------------------
- function changeArray()
- if side == "south" then
- array = {"south","west","north","east"}
- elseif side == "north" then
- array = {"north","east","south","west"}
- elseif side == "east" then
- array = {"east","south","west","north"}
- elseif side == "west" then
- array = {"west","north","east","south"}
- end
- end
- function setAwal(vector)
- awal = vector
- end
- function getSide()
- return side
- end
- function checkside()
- local a = vector.new(gps.locate())
- turtle.dig()
- turtle.forward()
- local b = vector.new(gps.locate())
- local c = a-b
- if c.z == -1 then
- side = "south"
- elseif c.z == 1 then
- side = "north"
- elseif c.x == -1 then
- side ="east"
- elseif c.x == 1 then
- side ="west"
- end
- changeArray()
- a = b
- turtle.back()
- end
- function changeside(wside)
- local i = 1
- while side ~= wside do
- i = i + 1
- turtle.turnRight()
- side = array[i]
- end
- changeArray()
- end
- function goTo(destination,sideaw)
- turtle.dig()
- while not turtle.forward() do
- turtle.turnRight()
- turtle.dig()
- end
- checkside()
- local posnow = vector.new(gps.locate())
- local distance = destination-posnow
- if distance.y >0 then
- for i = distance.y, 1, -1 do
- turtle.digUp()
- turtle.up()
- end
- elseif distance.y <0 then
- for i = distance.y, -1 do
- turtle.digDown()
- turtle.down()
- end
- end
- local wside=nil
- -- change side to x
- if distance.x >0 then
- wside = "east"
- changeside(wside)
- elseif distance.x <0 then
- wside = "west"
- changeside(wside)
- end
- --move to x
- if distance.x >0 then
- for i = distance.x, 1, -1 do
- turtle.dig()
- turtle.forward()
- end
- elseif distance.x <0 then
- for i = distance.x, -1 do
- turtle.dig()
- turtle.forward()
- end
- end
- -- change side to z
- if distance.z >0 then
- wside = "south"
- changeside(wside)
- elseif distance.z <0 then
- wside = "north"
- changeside(wside)
- end
- --move to z
- if distance.z >0 then
- for i = distance.z, 1, -1 do
- turtle.dig()
- turtle.forward()
- end
- elseif distance.z <0 then
- for i = distance.z , -1 do
- turtle.dig()
- turtle.forward()
- end
- end
- changeside(sideaw)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement