Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- local x1
- local y1
- local z1
- function printUsage()
- print("<Nom_du_programme> x,y,z")
- end
- function deplcacement(i,step,di)
- while i ~= di do
- turtle.forward()
- i = i + step
- end
- end
- if #tArgs <= 2 then
- printUsage()
- return
- else
- xcord = tonumber(tArgs[1])
- ycord = tonumber(tArgs[2])
- zcord = tonumber(tArgs[3])
- x,y,z = gps.locate()
- local home = vector.new(xcord, ycord, zcord)
- local position = vector.new(gps.locate(5))
- local displacement = position - home
- print("I am ", tostring(displacement), " away from home!!!")
- t = {}
- for i in string.gmatch(tostring(displacement),"([^,]+)") do
- table.insert(t,i)
- end
- x1 = t[1]
- y1 = t[2]
- z1 = t[3]
- if tonumber(z1) < 0 then
- turtle.turnLeft()
- turtle.turnLeft()
- deplcacement(0,-1,z1)
- else
- deplcacement(1,1,z1)
- end
- if tonumber(x1) < 0 then
- turtle.turnRight()
- deplcacement(0,-1,x1)
- else
- turtle.turnLeft()
- deplcacement(1,1,x1)
- end
- --x1,y1,z1 = position - home
- --print(x1..y1..z1)
- --turtle.forward(z1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement