Streams

Streams

From BeamNG

Revision as of 00:17, 25 June 2014 by Metalmuncher (talk | contribs)

The streams are data that comes out of the main game in order to be displayed by the UI. This page will attempt to document all streams and how to get them into your app.

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
}

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 string Name of the wheel.
1 wd.radius float Radius of wheel.
2 wd.wheelDir float ???
3 w.angularVelocity float Current AV of the wheel.
4 w.lastTorque float ???
5 drivetrain.wheelInfo[wd.wheelID].lastSlip float ???
6 wd.lastTorqueMode float ???

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 int Number of deformed beams.
beams_broken int Number of broken beams.
beam_count int Total number of beams.
node_count int Total number of nodes.
total_weight float Total mass of all nodes.
wheel_weight float Mass of all wheel nodes.
wheel_count int 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