THEJean_Kevin

manequin droit animation

Aug 20th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. m = peripheral.wrap("top")
  2. os.loadAPI("ocs/apis/sensor")
  3. local radius = 6
  4. local left = true
  5.  
  6.  
  7.  
  8. function repos()
  9. m.setRotation("chest",0,-35,0)
  10. m.setRotation("left_arm",-50,23,31)
  11. m.setRotation("right_arm",-90,-4,-78)
  12.         --1
  13.         lx=-50
  14.         --12
  15.         ly=23
  16.         --8
  17.         lz=31
  18.         --31
  19.         cy=-35
  20.         --27
  21.         rx=-90
  22.         --31
  23.         ry=-4
  24.         --12
  25.         rz=-78
  26. end
  27.  
  28.  
  29.  
  30.  
  31. function indique()
  32.        
  33.     while left do
  34.        
  35.         m.setRotation("left_arm",lx,ly,lz)
  36.         if lx ~=-51 then
  37.         lx=lx-1
  38.         end
  39.         if ly ~=35 then
  40.         ly=ly+1
  41.         end
  42.         if lz ~=39 then
  43.         lz=lz+1
  44.         end
  45.        
  46.        
  47.         m.setRotation("chest",0,cy,0)
  48.         if cy ~=-66 then
  49.         cy=cy-1
  50.         elseif cy == -66 then
  51.         left= false
  52.         end
  53.        
  54.         m.setRotation("right_arm",rx,ry,rz)
  55.         if rx ~= -180 then
  56.         rx=rx-3
  57.         end
  58.         if ry ~= -35 then
  59.         ry=ry-1
  60.         end
  61.         if rz~= -90 then
  62.         rz=rz-1
  63.         end
  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
Advertisement
Add Comment
Please, Sign In to add comment