Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 10th, 2012  |  syntax: Lua  |  size: 1.64 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @name Throttle
  2. @inputs Forward Backward
  3. @outputs Thruster
  4. @persist O G
  5. @trigger
  6.  
  7.  
  8. timer("test", 100)
  9. if(clk("test"))
  10. {
  11.  G -= G/20
  12.  O += G
  13. Thruster = O
  14.  
  15.  
  16. if (Forward == 0 & Backward == 0){
  17.     Thruster = 0
  18.     O=0.1
  19.     G=1.1
  20. }
  21. if (Backward == 1){ Thruster=-Thruster}
  22. }
  23.  
  24.  
  25.  
  26. @name Hovering
  27. @inputs TopRight TopLeft BottomRight BottomLeft Up Down
  28. @outputs Cat TopRightThrust TopLeftThrust BottomRightThrust BottomLeftThrust
  29. @persist Nominal
  30. @trigger
  31.  
  32.  
  33. TopRightThrust = 0
  34. TopLeftThrust = 0
  35. BottomLeftThrust = 0
  36. BottomRightThrust = 0
  37.  
  38.  
  39.  
  40. if (TopRight < Nominal){
  41. TopRightThrust = (Nominal-TopRight)/5
  42. }
  43.  
  44. if (TopLeft < Nominal){
  45. TopLeftThrust = (Nominal-TopLeft)/5
  46. }
  47.  
  48.  
  49. if (BottomRight < Nominal){
  50. BottomRightThrust = (Nominal-BottomRight)/5
  51. }
  52. if (BottomLeft < Nominal){
  53. BottomLeftThrust = (Nominal-BottomLeft)/5
  54. }
  55.  
  56.  
  57.  
  58.  
  59. Cat = TopRight
  60.  
  61.  
  62.  
  63. @name Turning
  64. @inputs Right Left Speed
  65. @outputs RightThrust LeftThrust
  66. @persist
  67. @trigger
  68.  
  69.  
  70. RightThrust = Left
  71. LeftThrust = Right
  72.  
  73.  
  74.  
  75. @name Compensation
  76. runOnTick(1)
  77. Temp=entity(),Entity=(Temp:getConstraints():count() > 0 ? Temp:isWeldedTo() : Temp)
  78.  
  79. Angle=-Entity:angles()*15-Entity:angVel()*2
  80. Center=Entity:massCenter(),Right=Entity:right(),Forward=Entity:forward(),Up=Entity:up()
  81. Entity:applyForce((vec(0,0,9.015)-Entity:vel())*Entity:mass())
  82. Leverage=Entity:inertia():length()
  83.  
  84. Entity:applyOffsetForce( Up   *Angle:pitch(),Center-Forward*Leverage)
  85. Entity:applyOffsetForce(-Up   *Angle:pitch(),Center+Forward*Leverage)
  86. Entity:applyOffsetForce( Up   *Angle:roll() ,Center-Right  *Leverage)
  87. Entity:applyOffsetForce(-Up   *Angle:roll() ,Center+Right  *Leverage)