• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Mine 3

Igor169 Mar 28th, 2020 (edited) 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. local tArgs = { ... }
2. local x1
3. local y1
4. local z1
5.
6. function printUsage()
7.     print("<Nom_du_programme> x,y,z")
8. end
9.
10. function deplcacement(i,step,di)
11.     while i ~= di do
12.         turtle.forward()
13.         i = i + step
14.     end
15. end
16.
17.
18.     if #tArgs <= 2 then
19.         printUsage()
20.         return
21.     else
22.
23.     xcord = tonumber(tArgs[1])
24.     ycord = tonumber(tArgs[2])
25.     zcord = tonumber(tArgs[3])
26.
27.      x,y,z = gps.locate()
28.
29.  local home = vector.new(xcord, ycord, zcord)
30.  local position = vector.new(gps.locate(5))
31.  local displacement = position - home
32.
33.   print("I am ", tostring(displacement), " away from home!!!")
34.
35.   t = {}
36.   for i in string.gmatch(tostring(displacement),"([^,]+)") do
37.     table.insert(t,i)
38.   end
39.
40.    x1 = t[1]
41.    y1 = t[2]
42.    z1 = t[3]
43.
44.
45.   if tonumber(z1) < 0 then
46.     turtle.turnLeft()
47.     turtle.turnLeft()
48.     deplcacement(0,-1,z1)
49.     else
50.     deplcacement(1,1,z1)
51.   end
52.
53.
54.   if tonumber(x1) < 0 then
55.     turtle.turnRight()
56.     deplcacement(0,-1,x1)
57.     else
58.     turtle.turnLeft()
59.     deplcacement(1,1,x1)
60.   end
61.
62.
63.
64.   --x1,y1,z1 = position - home
65.   --print(x1..y1..z1)
66.   --turtle.forward(z1)
67. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top