28 posts
Posted 12 July 2012 - 03:48 PM
Hi there,everyone i got another problem,i want my turtle to have a "home" point so i can move it to chop trees,and with a single command,let it return home at certain coordinates.
How to do this? :)/>/>
286 posts
Location
Bonn Germany
Posted 12 July 2012 - 04:10 PM
Well this is not so easy. You can of course create a gps network and compare the current turtles position with the one of its home point but you can't simply move to this point because there might are in between.
homex = 0 --modify this
homey = 0
homez = 0
x, y, z = gps.locate(10, false)
divx = x - homex
divy = y - homey
divz = z - homez
turtle.forward()
x1, y1, z1 = gps.locate(10, false)
f = 0
if x1 < x then f = 3 end
if x1 > x then f = 1 end
if z1 < z then f = 0end
if z1 > z then f = 2 end
while f > 0 do
turtle.turnLeft()
f = f-1
end
for divz > 0 do
turtle.forward()
divz = divz -1
end
turtle.turnLeft()
for divx > 0 do
turtle.forward()
divx = divx -1
end
turtle.turnLeft()
for divz < 0 do
turtle.forward()
divz = divz +1
end
turtle.turnLeft()
for divx < 0 do
turtle.forward()
divx = divx +1
end
while divy > 0 do
turtle.down()
divy = divy -1
end
while divy < 0 do
turtle.up()
divy = divy +1
end
This is untested!!