EnergyStorage

EnergyStorage

From BeamNG

Revision as of 22:43, 1 March 2019 by Capkirk (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The game includes several types of energy storage that can be used by engines. A fuelTank of a vehicle stores fuel for CombustionEngines. It can be filled or emptied, whether by the player, being used by the engine, or by being ruptured by damage, and it's mass will vary with the volume and density of fuel contained in it. Although not necessary for a CombustionEngine to function, it allows a vehicle to drain, and run out of, fuel. Three fuel types are defined by the game; gasoline, diesel, and kerosene. However, by inputting the density and energy density of a fuel type, you can define your own fuel types.

An electricBattery stores power for an electricMotor. It can be charged or drained by the player, and is drained by electricMotors. It's mass will not be affected by it's capacity.

An n2oTank stores an oxidizer that can be used by nitrousOxideInjection to boost the power output of an engine. It cannot be filled or drained by the player, and is drained by nitrousOxideInjection systems, and can be ruptured if damaged. It's mass is not affected by the volume of fuel stored. Although it contains nitrous oxide by default, by inputting the energy density of an oxidizer, you can define your own oxidizer types.


fuelTank Jbeam Properties

Name Type Optional Default Value Description
energyStorage Table False N/A This is a table which defines what type of energy storage this is, and what it's name is.
energyType String True gasoline This variable defines what type of fuel is stored in the fuel tank. gasoline, diesel and kerosene are predefined, or you can enter your own fuel type.
breakTriggerBeam String False N/A This defines the breakGroup of the fuel tank. If any beams in this breakGroup are broken, the fuel tank will begin leaking.
energyDensity Number True 41000000 This variable defines the energy density of a custom fuel in MJ/kg. This can be easily found in the documentation of most potential fuels.
fuelLiquidDensity Number True 0.75 This variable defines the density of a custom fuel in kg/L. This can be easily found in the documentation of most potential fuels.
fuelCapacity Number True 0 This variable defines the maximum volume of a fuel tank in Liters.
startingFuelCapacity Number True fuelCapacity This variable defines how much fuel a fuel tank spawns with.

fuelTank Examples

Here is an example of an energyStorage section.

     "variables": [
        ["name", "type", "unit", "category", "default", "min", "max", "title", "description"]
        ["$fuel", "range", "L", "Chassis", 40, 0, 40, "Fuel Volume", "Initial fuel volume", {"stepDis":1}]
    ],
    "energyStorage": [
        ["type", "name"],
        ["fuelTank", "mainTank"],
    ],
    "mainTank": {
        "energyType":"gasoline",
        "fuelCapacity": 40,
        "startingFuelCapacity": "$fuel",
        "fuel": {"[engineGroup]:":["fuel"]},
        "breakTriggerBeam": "fuelTank",
    },

This example also contains tuning variables, to allow the player to adjust the amount of fuel in the fuel tank.

electricBattery Jbeam Properties

Name Type Optional Default Value Description
energyStorage Table False N/A This is a table which defines what type of energy storage this is, and what it's name is.
batteryCapacity Number True 0 This variable defines capacity of a battery, in kWh.
startingFuelCapacity Number True batteryCapacity This variable defines how much charge a battery spawns with.

electricBattery Examples

n2oTank Jbeam Properties

Name Type Optional Default Value Description
energyStorage Table False N/A This is a table which defines what type of energy storage this is, and what it's name is.
breakTriggerBeam String False N/A This defines the breakGroup of the fuel tank. If any beams in this breakGroup are broken, the n2o tank will begin leaking.
energyDensity Number True 8200000 This variable defines the energy density of a custom oxidizer in MJ/kg. This is set to 1/5 the energy density of gasoline by default, because a 1:5 ratio of gasoline and nitrous is used. If an oxidizer with a different ratio is desired, this number can be changed.
capacity Number True 0 This variable defines the maximum volume of a fuel tank in Liters.
startingCapacity Number True capacity This variable defines how much fuel a fuel tank spawns with.

n2oTank examples

Here is an example of an energyStorage section for n2o.

     "energyStorage": [
        ["type", "name"],
        ["n2oTank", "mainBottle"],
    ],
    "mainBottle": {
        "capacity": 4.54,
        "startingCapacity": 4.54,
    }
    "mainEngine": {
        "energyStorage": ["mainTank", "mainBottle"],
    }

This example also includes a section of engine code, to allow the engine to draw from the n2o tank.