How to do this?
Setting home coordinates for Turtle
Started by Macapple, Jul 12 2012 02:48 PM
1 reply to this topic
#1
Posted 12 July 2012 - 02: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?
/>
How to do this?
#2
Posted 12 July 2012 - 03: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.
This is untested!!
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!!
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











