Vehicle - stingray.Vehicle object reference - Stingray Lua API Reference

stingray.Vehicle object reference

Description

Interface to a physics vehicle.

A vehicle is a rigid body living in the physics world. The Lua Vehicle object will become invalid if the vehicle is destroyed.

Functions

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

stingray.Actor

The Actor associated with the vehicle.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

force :

stingray.Vector3

The force to apply to the vehicle.

Returns
This function does not return any values.

This will not induce a torque.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

integer

The current gear.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

number

The engine rotation speed, in radians per second.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

stingray.Vector3

The forward direction.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

number

The forward speed.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

boolean

Returns true if this vehicle physics model is tank, or false otherwise.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

boolean

Returns true if this vehicle physics model is wheeled, or false otherwise.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

boolean

Returns true if automatic gears are enabled, or false otherwise.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

boolean

Returns true if all wheels do not have contact with a drivable surface, and false otherwise.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

integer

The number of forward gears.

Neutral and reverse gears are not included.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

integer

The number of wheels on the vehicle.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

stingray.Vector3

The position of the vehicle chassis.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

accelerator :

number

The vehicle acceleration value. The acceleration value range is between 0 (no acceleration) and 1 (full acceleration).

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

enabled :

boolean

true to enable automatic gears for this vehicle, or false to disable.

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

speed :

number

The new engine rotation speed, in radians per second.

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

gear :

integer

The gear value applied to the vehicle. The gear range is between 1 and the maximum number of gears the vehicle has; use 0 for neutral; use -1 for reverse.

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

gear_down :

boolean

true to shift into a lower gear.

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

gear_up :

boolean

true to shift into a higher gear.

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

enabled :

boolean

true to enable input smoothing, or false to disable input smoothing.

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

fval :

number

The brake to be applied to the wheels on the left. The brake value range is between 0 (no brake) and 1 (full brake).

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

fval :

number

The thrust value applied to the wheels on the left. For tanks with standard drive model the thrust value range is between 0 (no thrust) and 1 (full thrust). For tanks with special drive model the range is between -1 (full backwards thrust) and 1 (full forward thrust).

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

fval :

number

The brake applied to the wheels on the right. The brake value range is between 0 (no brake) and 1 (full brake).

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

fval :

number

The thrust value applied to the wheels on the right. For tanks with standard drive model the thrust value range is between 0 (no thrust) and 1 (full thrust). For tanks with 'special' drive model the range is between -1 (full backwards thrust) and 1 (full forward thrust).

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

brake :

number

The brake to be applied to the wheels. The brake value range is between 0 (no brake) and 1 (full brake).

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

handbrake :

number

The handbrake applied to the wheel. The handbrake value range is between 0 (no handbrake) and 1 (full handbrake).

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

steer :

number

The steering value applied to the wheels. The steer value range is between -1 (full left) and 1 (full right).

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheels in the vehicle.

angle :

number

The new wheel rotation angle, in radians.

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

speed :

number

The new wheel rotation speed, in radians/sec.

Returns
This function does not return any values.
Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

number

The sideways speed.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

number

The steering angle, ranging from -1 (full left) to 1 (full right).

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

number

The suspension force.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

number

The suspension jounce, ranging from -1 (fully extended) to 1 (fully compressed)..

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

stingray.Vector3

The suspension line direction unit vector.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

stingray.Vector3

The suspension line start in world coordinates.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

stingray.Vector3

The normal of the contact between the specified wheel and the drivable surface, or the zero vector if the wheel is not in contact with a drivable surface.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

stingray.Vector3

The contact position between the specified wheel and the drivable surface it is in contact with, or the zero vector if the wheel is not in contact with a drivable surface.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

integer

The index of the drivable surface under the tire, or -1 if the tire is not in contact with any surface. The index corresponds to the drivable_surface array set up in the global.physics_properties data file.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

number

The friction applied to the tire.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

stingray.Vector3

The lateral direction of the tire, or the zero vector if the tire does not have contact with a drivable surface.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

number

The lateral slip of the tire. Increasing positive values are proportial to the amount of slip. A value of 0 indicates zero slip.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

stingray.Vector3

The longitudinal direction of the tire, or the zero vector if the tire does not have contact with a drivable surface.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

number

The longitudinal slip of the tire. Increasing positive values are proportial to the amount of slip. A value of 0 indicates zero slip.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.
Returns

stingray.Unit

The Unit that owns the vehicle, if any.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

number

The wheel rotation angle, in radians.

Parameters

self :

stingray.Vehicle

Specifies the object instance that this function will act on.

You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation.

wheel_index :

integer

The index of the wheel.

Returns

number

The rotation speed of the wheel, in radians per second.