
Untitled
By: a guest on
May 10th, 2012 | syntax:
Lua | size: 1.64 KB | hits: 20 | expires: Never
@name Throttle
@inputs Forward Backward
@outputs Thruster
@persist O G
@trigger
timer("test", 100)
if(clk("test"))
{
G -= G/20
O += G
Thruster = O
if (Forward == 0 & Backward == 0){
Thruster = 0
O=0.1
G=1.1
}
if (Backward == 1){ Thruster=-Thruster}
}
@name Hovering
@inputs TopRight TopLeft BottomRight BottomLeft Up Down
@outputs Cat TopRightThrust TopLeftThrust BottomRightThrust BottomLeftThrust
@persist Nominal
@trigger
TopRightThrust = 0
TopLeftThrust = 0
BottomLeftThrust = 0
BottomRightThrust = 0
if (TopRight < Nominal){
TopRightThrust = (Nominal-TopRight)/5
}
if (TopLeft < Nominal){
TopLeftThrust = (Nominal-TopLeft)/5
}
if (BottomRight < Nominal){
BottomRightThrust = (Nominal-BottomRight)/5
}
if (BottomLeft < Nominal){
BottomLeftThrust = (Nominal-BottomLeft)/5
}
Cat = TopRight
@name Turning
@inputs Right Left Speed
@outputs RightThrust LeftThrust
@persist
@trigger
RightThrust = Left
LeftThrust = Right
@name Compensation
runOnTick(1)
Temp=entity(),Entity=(Temp:getConstraints():count() > 0 ? Temp:isWeldedTo() : Temp)
Angle=-Entity:angles()*15-Entity:angVel()*2
Center=Entity:massCenter(),Right=Entity:right(),Forward=Entity:forward(),Up=Entity:up()
Entity:applyForce((vec(0,0,9.015)-Entity:vel())*Entity:mass())
Leverage=Entity:inertia():length()
Entity:applyOffsetForce( Up *Angle:pitch(),Center-Forward*Leverage)
Entity:applyOffsetForce(-Up *Angle:pitch(),Center+Forward*Leverage)
Entity:applyOffsetForce( Up *Angle:roll() ,Center-Right *Leverage)
Entity:applyOffsetForce(-Up *Angle:roll() ,Center+Right *Leverage)