THEJean_Kevin

animation manequin gauche

Aug 20th, 2016
117
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,20,0)
  10. m.setRotation("left_arm",-27,-4,39)
  11. m.setRotation("right_arm",-55,-15,-63)
  12. --23
  13.         lx=-27
  14.         --11
  15.         ly=-4
  16.         --30
  17.         lz=38
  18.         --15
  19.         cy=20
  20.         --16
  21.         rx=-55
  22.         --4
  23.         ry=-15
  24.         --8
  25.         rz=-63
  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 ~=-4 then
  37.         lx=lx+1
  38.         end
  39.         if ly ~=-15 then
  40.         ly=ly-1
  41.         end
  42.         if lz ~=-82 then
  43.         lz=lz-4
  44.         elseif lz==-82 then
  45.         left = false
  46.         end
  47.        
  48.        
  49.         m.setRotation("chest",0,cy,0)
  50.         if cy ~=35 then
  51.         cy=cy+1
  52.         end
  53.        
  54.         m.setRotation("right_arm",rx,ry,rz)
  55.         if rx ~= -39 then
  56.         rx=rx+1
  57.         end
  58.         if ry ~= -19 then
  59.         ry=ry-1
  60.         end
  61.         if rz~= -74 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