View difference between Paste ID: jPubj3xJ and nVpdJuhu
SHOW: | | - or go back to the newest paste.
1
m = peripheral.wrap("top")
2
os.loadAPI("ocs/apis/sensor")
3
local radius = 6
4
local left = true
5
6
7
8
function repos()
9-
m.setRotation("chest",0,20,0)
9+
m.setRotation("chest",0,-35,0)
10-
m.setRotation("left_arm",-27,-4,39)
10+
m.setRotation("left_arm",-50,23,31)
11-
m.setRotation("right_arm",-55,-15,-63)
11+
m.setRotation("right_arm",-90,-4,-78)
12-
--23
12+
		--1
13-
		lx=-27
13+
		lx=-50
14-
		--11
14+
		--12
15-
		ly=-4
15+
		ly=23
16-
		--30
16+
17-
		lz=38
17+
		lz=31
18-
		--15
18+
		--31
19-
		cy=20
19+
		cy=-35
20-
		--16
20+
		--27
21-
		rx=-55
21+
		rx=-90
22-
		--4
22+
		--31
23-
		ry=-15
23+
		ry=-4
24
		--12
25-
		rz=-63
25+
		rz=-78
26
end
27
28
29
30
31
function indique()
32
		
33
	while left do
34
		
35
		m.setRotation("left_arm",lx,ly,lz)
36-
		if lx ~=-4 then
36+
		if lx ~=-51 then
37-
		lx=lx+1
37+
		lx=lx-1
38
		end
39-
		if ly ~=-15 then
39+
		if ly ~=35 then
40-
		ly=ly-1
40+
		ly=ly+1
41
		end
42-
		if lz ~=-82 then
42+
		if lz ~=39 then
43-
		lz=lz-4
43+
		lz=lz+1
44-
		elseif lz==-82 then
44+
45-
		left = false
45+
46
		
47
		m.setRotation("chest",0,cy,0)
48
		if cy ~=-66 then
49
		cy=cy-1
50-
		if cy ~=35 then
50+
		elseif cy == -66 then
51-
		cy=cy+1
51+
		left= false
52
		end
53
		
54
		m.setRotation("right_arm",rx,ry,rz)
55-
		if rx ~= -39 then
55+
		if rx ~= -180 then
56-
		rx=rx+1
56+
		rx=rx-3
57
		end
58-
		if ry ~= -19 then
58+
		if ry ~= -35 then
59
		ry=ry-1
60
		end
61-
		if rz~= -74 then
61+
		if rz~= -90 then
62
		rz=rz-1
63
		end
64
		sleep(0.01)
65
66
	end
67
end
68
69
function position(x)
70
if x == false then
71
repos()
72
end
73
if x == true then
74
left = true
75
indique()
76
end
77
end
78
79
80
81
function distance(pos)
82
local xd = pos.X
83
local yd = pos.Y
84
local zd = pos.Z
85
return math.sqrt(xd*xd + yd*yd + zd*zd)
86
end
87
repos()
88
local proximity = sensor.wrap("bottom")
89
while true do
90
 local signal = false
91
  local targets = proximity.getTargets()
92
  for k, v in pairs(targets) do
93
  if distance(v.Position) < radius then
94
  signal = true   
95
  end
96
 end
97
98
 sleep(2)
99
 position(signal)
100
 print(signal)
101
102
 end