View difference between Paste ID: nVpdJuhu and 2dwN5SE1
SHOW: | | - or go back to the newest paste.
1
m = peripheral.wrap("top")
2
os.loadAPI("ocs/apis/sensor")
3-
local radius = 8
3+
local radius = 6
4
local left = true
5
6
7
8
function repos()
9
m.setRotation("chest",0,20,0)
10
m.setRotation("left_arm",-27,-4,39)
11
m.setRotation("right_arm",-55,-15,-63)
12
--23
13-
for i=20,35 do
13+
		lx=-27
14-
sleep(0.1)
14+
		--11
15-
m.setRotation("chest",0,i,0)
15+
		ly=-4
16
		--30
17-
while left do
17+
		lz=38
18-
x=-27
18+
		--15
19-
y=-4
19+
		cy=20
20-
z=38
20+
		--16
21-
m.setRotation("left_arm",x,y,z)
21+
		rx=-55
22-
sleep(0.01)
22+
		--4
23-
if x ~=-4 then
23+
		ry=-15
24-
x=x+1
24+
		--8
25
		rz=-63
26-
if y ~=-15 then
26+
27-
y=y-1
27+
28
29-
if z ~=-82 then
29+
30-
z=z-2
30+
31
function indique()
32
		
33
	while left do
34
		
35
		m.setRotation("left_arm",lx,ly,lz)
36
		if lx ~=-4 then
37
		lx=lx+1
38
		end
39
		if ly ~=-15 then
40
		ly=ly-1
41
		end
42
		if lz ~=-82 then
43
		lz=lz-4
44
		elseif lz==-82 then
45
		left = false
46
		end
47
		
48
		
49
		m.setRotation("chest",0,cy,0)
50
		if cy ~=35 then
51
		cy=cy+1
52
		end
53
		
54
		m.setRotation("right_arm",rx,ry,rz)
55
		if rx ~= -39 then
56
		rx=rx+1
57
		end
58
		if ry ~= -19 then
59
		ry=ry-1
60-
 repos()
60+
		end
61
		if rz~= -74 then
62-
 sleep(3)
62+
		rz=rz-1
63-
 indique()
63+
		end
64-
 sleep(3)
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