Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("top")
- os.loadAPI("ocs/apis/sensor")
- local radius = 8
- local left = true
- function repos()
- m.setRotation("chest",0,20,0)
- m.setRotation("left_arm",-27,-4,39)
- m.setRotation("right_arm",-55,-15,-63)
- end
- function indique()
- for i=20,35 do
- sleep(0.1)
- m.setRotation("chest",0,i,0)
- end
- while left do
- x=-27
- y=-4
- z=38
- m.setRotation("left_arm",x,y,z)
- sleep(0.01)
- if x ~=-4 then
- x=x+1
- end
- if y ~=-15 then
- y=y-1
- end
- if z ~=-82 then
- z=z-2
- end
- end
- end
- function distance(pos)
- local xd = pos.X
- local yd = pos.Y
- local zd = pos.Z
- return math.sqrt(xd*xd + yd*yd + zd*zd)
- end
- repos()
- local proximity = sensor.wrap("bottom")
- while true do
- local signal = false
- local targets = proximity.getTargets()
- for k, v in pairs(targets) do
- if distance(v.Position) < radius then
- signal = true
- end
- end
- repos()
- print(signal)
- sleep(3)
- indique()
- sleep(3)
- end
Advertisement
Add Comment
Please, Sign In to add comment