# Untitled

By: a guest on Aug 19th, 2012  |  syntax: Lua  |  size: 1.82 KB  |  hits: 6  |  expires: Never
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
1. local x = -886
2. local y = 514
3. local z = 64
4. local dx = 0
5. local dz = 0
6. local dy = 0
7. local id = os.computerID()
8. rednet.open("right")
9. rednet.send(607," activated at"..x..", "..y..", "..z.." distance:")
10.
11. function goToAndExcavate(fx,fy)
12.  goToPos(fx,fy, 100)
13.  shell.run("excavate", 1)
14.  travelY(1)
15.  goToPos(-879,64,526)
16. end
17.
18.
19. function travelX(a)
20.  print("going "..a.." along x")
21.  local distanceGone =0
22.  if (a>0)then
23.   while(turtle.forward()and distanceGone<a) do
24.    if(distanceGone<a) then
25.     x=x+1
26.     distanceGone = distanceGone+1
27.    end
28.   end
29.  else if(a>0) then
30.   while(turtle.back()and distanceGone<a) do
31.    if(distanceGone<a) then
32.     x=x-1
33.     distanceGone = distanceGone-1
34.    end
35.   end
36.  end
37. end
38. end
39. function travelZ(a)
40.  print("going "..a.." along z")
41.  turtle.turnRight()
42.  local distanceGone =0
43.  if (a>0)then
44.   while(turtle.back()and distanceGone<a) do
45.    if(distanceGone<a) then
46.     z=z+1
47.     distanceGone = distanceGone+1
48.    end
49.   end
50.  else if(a>0) then
51.   while(turtle.back()and distanceGone<a) do
52.    if(distanceGone<a) then
53.     z=z-1
54.     distanceGone = distanceGone-1
55.    end
56.   end
57.  end
58. end
59.  turtle.turnLeft()
60. end
61. function travelY(a)
62.  print("going "..a.." along y")
63.  local distanceGone =0
64.  if (a>0)then
65.   while(turtle.down()and distanceGone<a) do
66.    if(distanceGone<a) then
67.     y=y+1
68.     distanceGone = distanceGone+1
69.    end
70.   end
71.  else if(a>0) then
72.   while(turtle.up()and distanceGone<a) do
73.    if(distanceGone<a) then
74.     y=y-1
75.     distanceGone = distanceGone-1
76.    end
77.   end
78.  end
79. end
80. end
81. function goToPos(newX, newZ, newY )
82.   shell.run("go","forward", newX-x)
83.   shell.run("go","right", 1)
84.   shell.run("go","forward", newZ-z)
85.   shell.run("go","left", 1)
86.   shell.run("go","up", newY-y)
87.   y=newY
88.   z=newZ
89.   x=newX
90. end
91. goToPos(-879,526,64)
92. print(x)
93. print(y)
94. print(x)
95. print(Z)