This feature is supported as of BeamNG.tech and .drive version 0.31 to latest.
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 input maps 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
example value for Box type:
{"x":0.25, "y":0.05, "z":0.08}
example value for Sphere type:
Uses the intrinsic Euler -X -Z -Y rotation system, the center of rotation being the corner of the box that defines position.
example value:
Used for animation and alike. Unused right now.
Used for animation and alike. Unused right now.
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
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.
Required arguments
Commonly used values are:
- action0 = left mouse button
- action1 = shift + left mouse button
- action2 = middle mouse button
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.
List of available vanilla interactions
Event
controller.getControllerSafe(‘door_L_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘door_R_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘door_FL_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘door_FR_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘door_RL_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘door_RR_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘door_RL_coupler’).toggleGroupConditional({{ ‘door_FL_coupler’,‘attached’,‘vehicle.advancedCouplerControl.openFrontDoorFirst’}})
Event
controller.getControllerSafe(‘door_RR_coupler’).toggleGroupConditional({{ ‘door_FR_coupler’,‘attached’,‘vehicle.advancedCouplerControl.openFrontDoorFirst’}})
Event
controller.getControllerSafe(‘rearDoorCoupler’).toggleGroup()
Event
controller.getControllerSafe(‘barndoor_L_coupler’).toggleGroupConditional({{ ‘barndoor_R_coupler’,‘attached’,‘vehicle.advancedCouplerControl.openOtherSideFirst’}})
Event
controller.getControllerSafe(‘barndoor_L_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘barndoor_RR_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘barndoor_RL_coupler’).toggleGroupConditional({{ ‘barndoor_RR_coupler’,‘attached’,‘vehicle.advancedCouplerControl.openOtherSideFirst’}})
Event
controller.getControllerSafe(‘barndoor_R_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘sidedoor_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘sidedoor_F_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘sidedoor_R_coupler’).toggleGroupConditional({{ ‘sidedoor_F_coupler’,‘attached’,‘vehicle.advancedCouplerControl.openOtherSideFirst’}})
Event
controller.getControllerSafe(‘hoodCatchCoupler’).toggleGroupConditional({{ ‘hoodLatchCoupler’,‘attached’,‘vehicle.advancedCouplerControl.releaseHoodFirstInterior’}})
Event
controller.getControllerSafe(‘hoodLatchCoupler’).toggleGroup()
Action
toggle_cargodoorRL
Event
controller.getControllerSafe(‘cargoDoorRLCoupler’).toggleGroup()
Action
toggle_cargodoorRR
Event
controller.getControllerSafe(‘cargoDoorRRCoupler’).toggleGroup()
Event
controller.getControllerSafe(’tailgateCoupler’).toggleGroup()
Event
controller.getControllerSafe(’tailgateCoupler’).toggleGroupConditional({{ ’tailgateCouplerUpper’,‘attached’,‘vehicle.advancedCouplerControl.openUpperPartFirst’},{‘spareholderCoupler’,‘attached’,‘vehicle.advancedCouplerControl.openSpareHolderFirst’}})
Event
controller.getControllerSafe(’tailgateCouplerUpper’).toggleGroup()
Action
tailgate_lower_alt
Event
controller.getControllerSafe(’tailgateCoupler’).toggleGroupConditional({{ ‘spareholderCoupler’,‘attached’,‘vehicle.advancedCouplerControl.openSpareHolderFirst’}})
Action
tailgate_upper_alt
Event
controller.getControllerSafe(’tailgateCouplerUpper’).toggleGroupConditional({{ ’tailgateCoupler’,‘attached’,‘vehicle.advancedCouplerControl.openLowerPartFirst’}})
Event
controller.getControllerSafe(’tailgateCatchCoupler’).toggleGroupConditional({{ ’tailgateLatchCoupler’,‘attached’,‘vehicle.advancedCouplerControl.releaseTailgateFirstInterior’}})
Event
controller.getControllerSafe(’tailgateLatchCoupler’).toggleGroup()
Event
controller.getControllerSafe(’trunkCoupler’).toggleGroup()
Event
controller.getControllerSafe(‘hatchCoupler’).toggleGroup()
Event
controller.getControllerSafe(‘decklidCoupler’).toggleGroup()
Event
controller.getControllerSafe(‘spareholderCoupler’).toggleGroup()
Event
controller.getControllerSafe(‘step_coupler’).toggleGroup()
Event
controller.getControllerSafe(‘roofboxCoupler’).toggleGroup()
Event
controller.getControllerSafe(’lidBCoupler’).toggleGroup()
Event
controller.getControllerSafe(’lidFCoupler’).toggleGroup()
Event
controller.getControllerSafe(’lidRCoupler’).toggleGroup()
Event
controller.getControllerSafe(’lidB2Coupler’).toggleGroup()
Event
controller.getControllerSafe(’lidF2Coupler’).toggleGroup()
Event
controller.getControllerSafe(’lidR2Coupler’).toggleGroup()
Event
controller.getControllerSafe(‘portaPottyDoorCoupler’).toggleGroupConditional({{ ‘portaPottyLockCoupler’,‘attached’,‘vehicle.advancedCouplerControl.portaPotty’}})
Event
controller.getControllerSafe(‘portaPottyLockCoupler’).toggleGroup()
Event
electrics.set_lightbar_signal(electrics.values.lightbar == 0 and 1 or 0)
Event
electrics.set_lightbar_signal(electrics.values.lightbar == 0 and 1 or 0)
Event
electrics.set_lightbar_signal(electrics.values.lightbar == 2 and 1 or 2)
Action
toggle_lightbar_siren
Event
electrics.set_lightbar_signal(electrics.values.lightbar == 0 and 2 or 0)
Action
lightbar_setmode_1
Event
for _, v in pairs(controller.getControllersByType(’lightbar’)) do v.setModeIndex(1) end
Action
lightbar_setmode_2
Event
for _, v in pairs(controller.getControllersByType(’lightbar’)) do v.setModeIndex(2) end
Action
lightbar_setmode_3
Event
for _, v in pairs(controller.getControllersByType(’lightbar’)) do v.setModeIndex(3) end
Action
lightbar_setmode_4
Event
for _, v in pairs(controller.getControllersByType(’lightbar’)) do v.setModeIndex(4) end
Action
toggle_lightbar_mode
Event
for _ ,v in pairs(controller.getControllersByType(’lightbar’)) do v.toggleMode() end
Action
fifthwheelDecouple
Event
controller.getControllerSafe(‘fifthwheel’).detachFifthwheel()
Event
beamstate.toggleCouplers(‘pintle’, true, false, false)
Event
controller.getControllerSafe(’trailerFeet’).moveFeet(-VALUE)
Event
controller.getControllerSafe(’trailerFeet’).moveFeet(VALUE)
Event
electrics.values.feet = 1 - (electrics.values.feet or 0)
Action
hydraulics_jump_full
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsPosition({‘full’},1,15)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘full’},0.9)
Action
hydraulics_jump_front
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsPosition({‘frontAxle’},1,15)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘frontAxle’},1)
Action
hydraulics_jump_rear
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsPosition({‘rearAxle’},1,15)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘rearAxle’},1)
Action
hydraulics_jump_left
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsPosition({’leftSide’},1,15)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({’leftSide’},1)
Action
hydraulics_jump_right
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsPosition({‘rightSide’},1,15)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘rightSide’},1)
Action
hydraulics_lower_full
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘full’},0.1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘full’},0)
Action
hydraulics_raise_full
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘full’},true,1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘full’},false,1)
Action
hydraulics_lower_front
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘frontAxle’},0.1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘frontAxle’},0)
Action
hydraulics_lower_rear
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘rearAxle’},0.1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘rearAxle’},0)
Action
hydraulics_lower_FL
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘frontLeft’},0.1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘frontLeft’},0)
Action
hydraulics_lower_FR
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘frontRight’},0.1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘frontRight’},0)
Action
hydraulics_lower_RL
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘rearLeft’},0.1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘rearLeft’},0)
Action
hydraulics_lower_RR
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘rearRight’},0.1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsBleed({‘rearRight’},0)
Action
hydraulics_raise_front
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘frontAxle’},true,1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘frontAxle’},false,1)
Action
hydraulics_raise_rear
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘rearAxle’},true,1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘rearAxle’},false,1)
Action
hydraulics_raise_FL
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘frontLeft’},true,1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘frontLeft’},false,1)
Action
hydraulics_raise_FR
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘frontRight’},true,1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘frontRight’},false,1)
Action
hydraulics_raise_RL
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘rearLeft’},true,1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘rearLeft’},false,1)
Action
hydraulics_raise_RR
onDown
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘rearRight’},true,1)
onUp
controller.getControllerSafe(‘hydraulicSuspension’).setGroupsMomentaryIncrease({‘rearRight’},false,1)
- Shipping container couplers
Action
container_attach_h_bot
Event
beamstate.toggleCouplers(‘cp1_h’, true)
Action
container_attach_h_top
Event
beamstate.toggleCouplers(‘cp2_h’, true)
Action
container_attach_v_top
Event
beamstate.toggleCouplers(‘cp_v’, true)
Event
electrics.values.jatoInput = 1 - (electrics.values.jatoInput or 0)
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.
Optional arguments
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, "energyStorage.getStorageSafe('mainAirTank'):toggleConsumerPressureCoef()""title": "vehicle.interaction.pneumatics.trailerAirSupply.toggle.title", "desc": "vehicle.interaction.pneumatics.trailerAirSupply.toggle.desc" },