Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xp1,yp1,zp1 = gps.locate()
- print("veuillez entrer les coordonnes")
- write ("x: ")
- xd = tonumber(read())
- write ("\ny: ")
- yd = tonumber(read())+1
- write ("\nz: ")
- zd = tonumber(read())
- -- voir dans quel sens est la tortue
- turtle.forward()
- local xp2,yp2,zp2 = gps.locate()
- if xd < xp2 then
- if xp1 < xp2 then
- turtle.turnRight()
- turtle.turnRight()
- elseif xp1 == xp2 and zp1 < zp2 then
- turtle.turnRight()
- elseif xp1 == xp2 and zp1 > zp2 then
- turtle.turnLeft()
- end
- end
- if xd > xp2 then
- if xp1 > xp2 then
- turtle.turnRight()
- turtle.turnRight()
- elseif xp1 == xp2 and zp1 < zp2 then
- turtle.turnLeft()
- elseif xp1 == xp2 and zp1 > zp2 then
- turtle.turnRight()
- end
- end
- if xd == xp2 then
- if zp1 > zp2 and zp2 < zd then
- turtle.turnLeft()
- turtle.turnLeft()
- elseif zp1 < zp2 and zp2 > zd then
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- -- faire déplacer la tortue
- while xp2~=xd or yp2~=yd or zp2~=zd do
- -- xd < xp2
- if xd < xp2 then
- for i = 0, 1 do
- if xp2~= xd then
- if turtle.forward() then
- if yd > yp2 and yd ~= yp2 then
- turtle.up()
- xp2,yp2,zp2 = gps.locate()
- elseif yd < yp2 and yd ~= yp2 then
- turtle.down()
- xp2,yp2,zp2 = gps.locate()
- end
- xp2,yp2,zp2 = gps.locate()
- else
- while not turtle.forward() do
- if not turtle.up() then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- xp2,yp2,zp2 = gps.locate()
- if not turtle.forward() then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- if zp2 > zd then
- turtle.turnRight()
- for k = 0 , 1 do
- if zp2 ~= zd then
- if turtle.forward() then
- if yd > yp2 and yd ~= yp2 then
- turtle.up()
- xp2,yp2,zp2 = gps.locate()
- elseif yd < yp2 and yd ~= yp2 then
- turtle.down()
- xp2,yp2,zp2 = gps.locate()
- end
- xp2,yp2,zp2 = gps.locate()
- else
- while not turtle.forward() do
- if not turtle.up() then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- xp2,yp2,zp2 = gps.locate()
- if not turtle.forward() then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- if xd < xp2 then
- turtle.turnLeft()
- end
- elseif zp2 < zd then
- turtle.turnLeft()
- for k=0,2 do
- if zp2 ~= zd then
- if turtle.forward() then
- if yd > yp2 and yd ~= yp2 then
- turtle.up()
- xp2,yp2,zp2 = gps.locate()
- elseif yd < yp2 and yd ~= yp2 then
- turtle.down()
- xp2,yp2,zp2 = gps.locate()
- end
- xp2,yp2,zp2 = gps.locate()
- else
- while not turtle.forward() do
- if not turtle.up() then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- xp2,yp2,zp2 = gps.locate()
- if not turtle.forward() then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- if xd < xp2 then
- turtle.turnRight()
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- --xd > xp2
- if xd > xp2 then
- for i = 0, 1 do
- if xp2~= xd then
- if turtle.forward() then
- if yd > yp2 and yd ~= yp2 then
- turtle.up()
- xp2,yp2,zp2 = gps.locate()
- elseif yd < yp2 and yd ~= yp2 then
- turtle.down()
- xp2,yp2,zp2 = gps.locate()
- end
- xp2,yp2,zp2 = gps.locate()
- else
- while not turtle.forward() do
- if not turtle.up() then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- xp2,yp2,zp2 = gps.locate()
- if not turtle.forward() then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- if zp2 > zd then
- turtle.turnLeft()
- for k = 0 , 1 do
- if zp2 ~= zd then
- if turtle.forward() then
- if yd > yp2 and yd ~= yp2 then
- turtle.up()
- xp2,yp2,zp2 = gps.locate()
- elseif yd < yp2 and yd ~= yp2 then
- turtle.down()
- xp2,yp2,zp2 = gps.locate()
- end
- xp2,yp2,zp2 = gps.locate()
- else
- while not turtle.forward() do
- if not turtle.up() then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- xp2,yp2,zp2 = gps.locate()
- if not turtle.forward() then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- if xd > xp2 then
- turtle.turnRight()
- end
- elseif zp2 < zd then
- turtle.turnRight()
- for k=0,1 do
- if zp2 ~= zd then
- if turtle.forward() then
- if yd > yp2 and yd ~= yp2 then
- turtle.up()
- xp2,yp2,zp2 = gps.locate()
- elseif yd < yp2 and yd ~= yp2 then
- turtle.down()
- xp2,yp2,zp2 = gps.locate()
- end
- xp2,yp2,zp2 = gps.locate()
- else
- while not turtle.forward() do
- if not turtle.up() then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- xp2,yp2,zp2 = gps.locate()
- if not turtle.forward() then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- if xd > xp2 then
- turtle.turnLeft()
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- -- xd = xp2
- if xd == xp2 then
- while zp2 ~= zd do
- if turtle.forward() then
- if yd > yp2 and yd ~= yp2 then
- turtle.up()
- xp2,yp2,zp2 = gps.locate()
- elseif yd < yp2 and yd ~= yp2 then
- turtle.down()
- xp2,yp2,zp2 = gps.locate()
- end
- xp2,yp2,zp2 = gps.locate()
- else
- while not turtle.forward() do
- if not turtle.up() then
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- xp2,yp2,zp2 = gps.locate()
- if not turtle.forward() then
- turtle.turnLeft()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- if xp2 == xd and zp2 == zd and yp2 ~= yd then
- if yd < yp2 then
- while yp2 ~= yd do
- turtle.down()
- xp2,yp2,zp2 = gps.locate()
- end
- elseif yd > yp2 then
- while yp2 ~= yd do
- turtle.up()
- xp2,yp2,zp2 = gps.locate()
- end
- end
- end
- end
- print("\nfin")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement