Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m = peripheral.wrap("top")
- os.loadAPI("ocs/apis/sensor")
- local radius = 6
- 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)
- --23
- lx=-27
- --11
- ly=-4
- --30
- lz=38
- --15
- cy=20
- --16
- rx=-55
- --4
- ry=-15
- --8
- rz=-63
- end
- function indique()
- while left do
- m.setRotation("left_arm",lx,ly,lz)
- if lx ~=-4 then
- lx=lx+1
- end
- if ly ~=-15 then
- ly=ly-1
- end
- if lz ~=-82 then
- lz=lz-4
- elseif lz==-82 then
- left = false
- end
- m.setRotation("chest",0,cy,0)
- if cy ~=35 then
- cy=cy+1
- end
- m.setRotation("right_arm",rx,ry,rz)
- if rx ~= -39 then
- rx=rx+1
- end
- if ry ~= -19 then
- ry=ry-1
- end
- if rz~= -74 then
- rz=rz-1
- end
- sleep(0.01)
- end
- end
- function position(x)
- if x == false then
- repos()
- end
- if x == true then
- left = true
- indique()
- 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
- sleep(2)
- position(signal)
- print(signal)
- end
Advertisement
Add Comment
Please, Sign In to add comment