Triggers2

Triggers2 is an improvement of the Triggers section. Combined with the triggerEventLinks2 and actionsEnabled sections, it offers a more natural link between triggers and input actions. These sections make it possible to show and hide certain actions on the UI depending on the parts equipped on the vehicle.

Interaction maps

Triggers2 require an action map or an interaction map in order to work. The interaction map can be defined in a file with a *.interaction.json suffix. The format of the file is the same as of input_actions.json , and it can replace that file. The keyboard and controller inputmaps associated with it will still work after the name change. There can be many files with the *.interaction.json suffix for modding purposes. There is also a shared interaction map in the common vehicle folder which contains some generic interactions such as door latches. Example of an interaction map file:

{
    "fileversion": 2,
    "actions": {
        //the content here is the same as in input_actions.json
        "sleeper_door_R":      {"order":   50.1, "onDown":"controller.getControllerSafe('sleeperDoorRCoupler').toggleGroup()", "title": "vehicle.interaction.sleeperDoorR.toggle.title", "desc": "vehicle.interaction.sleeperDoorR.toggle.desc" },
        "sleeper_door_L":      {"order":   50.2, "onDown":"controller.getControllerSafe('sleeperDoorLCoupler').toggleGroup()", "title": "vehicle.interaction.sleeperDoorL.toggle.title", "desc": "vehicle.interaction.sleeperDoorL.toggle.desc" },
    }
}

Triggers2 section arguments

Note: The “label” argument has been removed.

Required arguments

string
type
Uniquely identifies the trigger. Need to be unique for the whole vehicle
number
type
Reference node for the coordinate system
number
type
X node for the coordinate system
number
type
Y node for the coordinate system
string
type
Type of the trigger

valid values:

  • box
  • sphere
dictionary or number
type
{“x”:1, “y”:1, “z”:1} (box), 1 (sphere)
default
Size in 3D coordinates in case of Box type, radius in case of Sphere type

example value for Box type:

{"x":0.25, "y":0.05, "z":0.08}

example value for Sphere type:

0.25
dictionary
type
{“x”:0, “y”:0, “z”:0}
default
Rotation in Euler angles (degrees)

Uses the intrinsic Euler -X -Z -Y rotation system, the center of rotation being the corner of the box that defines position.

example value:

{"x":0, "y":0, "z":0}
dictionary
type
{“x”:0, “y”:0, “z”:0}
default
Rotation in Euler angles (degrees)
Used for animation and alike. Unused right now.
dictionary
type
{“x”:0, “y”:0, “z”:0}
default
Translation in local coordinate system
Used for animation and alike. Unused right now.
dictionary
type
{“x”:0, “y”:0, “z”:0}
default
Initial translation in local coordinate system

Uses the intrinsic Euler -X -Z -Y rotation system, the center of rotation being the corner of the box that defines position.

example value:

{"x":0.2, "y":0.26, "z":-0.05}

Optional arguments

string
type
The deformGroup that will disable the trigger when activated
array
type
Fraction based RGBA values that define the trigger’s color

example value:

"color": [0, 0, 1, 0.4]

TriggerEventLinks2 section arguments

Note: This section no longer refers to events. They are not supported by triggers2. The “triggerInput” argument is the same as the old “action” argument.

string
type
ID of the trigger from triggers2
string
type
Name of the input used to trigger the event

Commonly used values are:

  • action0 = left mouse button
  • action1 = right mouse button
  • action2 = middle mouse button
string
type
name of the action of the actionmap/interaction map to trigger

When used without a prefix, the name will be found in a file with a *.interaction.json suffix in the vehicle’s own folder or the common folder.

As of update 0.31 the common_default.interaction.json file available for all vehicles contains the following interactions:

  • “door_FL”: “onDown”:“controller.getControllerSafe(‘door_FL_coupler’).toggleGroup()”
  • “door_FR”: “onDown”:“controller.getControllerSafe(‘door_FR_coupler’).toggleGroup()”
  • “toggle_cargodoorRL”: “onDown”:“controller.getControllerSafe(‘cargoDoorRLCoupler’).toggleGroup()”
  • “toggle_cargodoorRR”: “onDown”:“controller.getControllerSafe(‘cargoDoorRRCoupler’).toggleGroup()”

When the “common:” prefix is added to the action name, it will be found in the VehicleCommonActionMap . You can see the available actions in lua\ge\extensions\core\input\actions\vehicle.json.

ActionsEnabled

Actions in *.interaction.json files, similarly to custom action maps, will be disabled by default (this means the tooltip showing the key mapped to them in top right corner of the screen will not be displayed, but the code will still be executed when that key is pressed). They can be enabled in Jbeam for a vehicle part that uses them using the ActionsEnabled section. It only takes one argument which is the ID of the action to enable. Example usage:

"actionsEnabled": [
    ["id"],
    ["door_FR"],
],

This is especially useful for vehicles that have lots of possible actions and only a small part of them is usable at a time depending on the chosen parts, like a semi truck with multiple upfit variants and interior controls.

Simple Example

A standard triggers2 setup for a door latch. It makes use of the door_FR action defined in common_default.interaction.json.

"triggers2":[
    ["id", "idRef:", "idX:", "idY:", "type", "size", "baseRotation", "rotation", "translation", "baseTranslation"],
    ["door_R", "d3r","d2r","d6r", "box", {"x":0.1, "y":0.03, "z":0.1}, {"x":0, "y":90, "z":0}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":0.24, "y":0.13, "z":-0.003}],
    ["door_R_int", "d4r","d5r","d1r", "box", {"x":0.1, "y":0.03, "z":0.1}, {"x":-0, "y":0, "z":-0}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":0.15, "y":-0.2, "z":0.0175}],
],
"triggerEventLinks2":[
    ["triggerId:triggers2", "triggerInput", "inputAction"],
    ["door_R", "action0", "door_FR"],
    ["door_R_int", "action0", "door_FR"],
],
"actionsEnabled": [
    ["id"],
    ["door_FR"],
],

Advanced Example

A more complicated setup, which uses colored triggers, actions from VehicleCommonActionMap, and a custom action from the vehicle’s interaction map.

"triggers2": [
    ["id", "idRef:", "idX:", "idY:", "type", "size", "baseRotation", "rotation", "translation", "baseTranslation"],
    ["sw_ignition", "dsh","dshr","dsh2", "box", {"x":0.05, "y":0.02, "z":0.02}, {"x":17, "y":-5, "z":8}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":-0.19, "y":0.155, "z":0.129}, {"deformGroup":"", "color": [0, 0, 1, 0.4]}],
    ["sw_starter", "dsh","dshr","dsh2", "box", {"x":0.05, "y":0.05, "z":0.05}, {"x":17, "y":-5, "z":8}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":-0.18, "y":0.24, "z":0.094}, {"deformGroup":"", "color": [0, 0, 1, 0.4]}],
    ["trailerAir",  "dsh","dshr","dsh2", "box", {"x":0.07, "y":0.03, "z":0.07}, {"x":8, "y":-8, "z":-24}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":0.025, "y":0.053, "z":-0.036}, {"deformGroup":"", "color": [0, 0, 1, 0.4]}],
    ["parkingBrake",  "dsh","dshr","dsh2", "box", {"x":-0.07, "y":0.03, "z":0.07}, {"x":8, "y":-8, "z":-24}, {"x":0, "y":0, "z":0}, {"x":0, "y":0, "z":0}, {"x":-0.001, "y":0.057, "z":-0.025}, {"deformGroup":"", "color": [0, 0, 1, 0.4]}],
],
"triggerEventLinks2": [
    ["triggerId:triggers2", "triggerInput", "inputAction"],
    ["sw_ignition", "action0", "common:activateStarterMotor"],
    ["sw_starter", "action0", "common:setIgnitionLevel3Momentary"],
    ["parkingBrake", "action0", "common:parkingbrake"],
    ["trailerAir", "action0", "toggleTrailerAirSupply"],
],
"actionsEnabled": [
    ["id"],
    ["toggleTrailerAirSupply"],
],

The corresponding action from the interaction map:

"toggleTrailerAirSupply":  {"order":   30.1, "onDown":"energyStorage.getStorageSafe('mainAirTank'):toggleConsumerPressureCoef()", "title": "vehicle.interaction.pneumatics.trailerAirSupply.toggle.title", "desc": "vehicle.interaction.pneumatics.trailerAirSupply.toggle.desc" },
Last modified: 16/4/2024 14:55

Any further questions?

Join our discord