Streams

Streams

From BeamNG

Revision as of 19:11, 24 June 2014 by Metalmuncher (talk | contribs)

This page will contain a list of GUI stream values, and some tips on how to use them.

wheelInfo

This is an array of wheels, for each wheel: This is an array of wheels, for each wheel:

Name Corresponding LUA names Type Description
0 wd.name
1 wd.radius
2 wd.wheelDir
3 w.angularVelocity
4 w.lastTorque
5 drivetrain.wheelInfo[wd.wheelID].lastSlip
6 wd.lastTorqueMode

engineInfo

This has stuff to do with the drivetrain and some general physics current values and settings.

Name Corresponding LUA Names Type Description
0 v.data.engine.idleRPM
1 v.data.engine.maxRPM
2 v.data.engine.shiftUpRPM
3 v.data.engine.shiftDownRPM
4 drivetrain.rpm
5 vdrivetrain.gear
6 v.data.engine.fwdGearCount
7 v.data.engine.revGearCount
8 drivetrain.torque
9 drivetrain.torqueTransmission
10 obj:getVelocity():length() WIP Airspeed
11 drivetrain.fuel
12 drivetrain.fuelCapacity
13 sensors
14 Settings.gravity

stats

The stats stream includes general node and beam structure statistics and information.

Note: While a number of the values are named "weight" they actually contain masses, in KG.

Name Type Description
beams_deformed intint Number of deformed beams.
beams_broken intint Number of broken beams.
beam_count intint Total number of beams.
node_count intint Total number of nodes.
total_weight float Total mass of all nodes.
wheel_weight float Mass of all wheel nodes.
wheel_count intint Number of wheels.

electrics

The electrics stream gives you access to all the electrics.lua values.

Name Type Description
wheelspeed float wheelspeedo
airspeed float airspeed
gear_A float Gear seleected in automatic mode
fuel float Percent of fuel
lowfuel float? Current engine torque
parkingbrake float Current wheel torque
signal_L float? Current wheel torque
signal_R float? Current wheel torque
abs float? Current wheel torque
lights float? Current wheel torque
throttle float Current throttle pedal position
brake float Current brake pedal position
clutch float Current clutch pedal position
steering float Current Steering wheel position
steering_input float Current original steering wheels position

sensors

torqueCurve

The torque curve stream includes torque vs RPM and power vs RPM tables.

Name Type Description
0 float Torque table
1 float Power table

Using Streams

In your app.json you define which streams you'd like to use in the data section:

{
    [...]

    "data": {
        "streams" : ["stream1","stream2","..."]
    }
}

In your app's update function, you can get the content of the streams as following:

MyApp.prototype.update = function(streams){
    streams.wheelInfo   //<- there's your wheelinfo
    streams.wheelInfo[0] // <- first wheel
    streams.wheelInfo[0][0] // <- name of the first wheel

    streams.sensors.position.x // <- x-Coordinate of the position of the current vehicle
}