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,-35,0)
- m.setRotation("left_arm",-50,23,31)
- m.setRotation("right_arm",-90,-4,-78)
- --1
- lx=-50
- --12
- ly=23
- --8
- lz=31
- --31
- cy=-35
- --27
- rx=-90
- --31
- ry=-4
- --12
- rz=-78
- end
- function indique()
- while left do
- m.setRotation("left_arm",lx,ly,lz)
- if lx ~=-51 then
- lx=lx-1
- end
- if ly ~=35 then
- ly=ly+1
- end
- if lz ~=39 then
- lz=lz+1
- end
- m.setRotation("chest",0,cy,0)
- if cy ~=-66 then
- cy=cy-1
- elseif cy == -66 then
- left= false
- end
- m.setRotation("right_arm",rx,ry,rz)
- if rx ~= -180 then
- rx=rx-3
- end
- if ry ~= -35 then
- ry=ry-1
- end
- if rz~= -90 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