Guest User

test

a guest
Aug 20th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. m = peripheral.wrap("top")
  2. os.loadAPI("ocs/apis/sensor")
  3. local radius = 8
  4. local left = true
  5.  
  6. function repos()
  7. m.setRotation("chest",0,20,0)
  8. m.setRotation("left_arm",-27,-4,39)
  9. m.setRotation("right_arm",-55,-15,-63)
  10. end
  11.  
  12. function indique()
  13. for i=20,35 do
  14. sleep(0.1)
  15. m.setRotation("chest",0,i,0)
  16. end
  17. while left do
  18. x=-27
  19. y=-4
  20. z=38
  21. m.setRotation("left_arm",x,y,z)
  22. sleep(0.01)
  23. if x ~=-4 then
  24. x=x+1
  25. end
  26. if y ~=-15 then
  27. y=y-1
  28. end
  29. if z ~=-82 then
  30. z=z-2
  31. end
  32.  
  33.  
  34.  
  35.  
  36. end
  37.  
  38.  
  39. end
  40.  
  41.  
  42.  
  43.  
  44. function distance(pos)
  45. local xd = pos.X
  46. local yd = pos.Y
  47. local zd = pos.Z
  48. return math.sqrt(xd*xd + yd*yd + zd*zd)
  49. end
  50. repos()
  51. local proximity = sensor.wrap("bottom")
  52. while true do
  53.  local signal = false
  54.   local targets = proximity.getTargets()
  55.   for k, v in pairs(targets) do
  56.   if distance(v.Position) < radius then
  57.   signal = true  
  58.   end
  59.  end
  60.  repos()
  61.  print(signal)
  62.  sleep(3)
  63.  indique()
  64.  sleep(3)
  65.  end
Advertisement
Add Comment
Please, Sign In to add comment