Input Actions
Loads and manages input action definitions from JSON files. Actions define what happens when an input binding triggers (key press, axis movement, etc.), including the command context (vehicle Lua, GE
Loads and manages input action definitions from JSON files. Actions define what happens when an input binding triggers (key press, axis movement, etc.), including the command context (vehicle Lua, GE Lua, etc.) and action map assignment.
Public API
| Function | Signature | Description |
|---|---|---|
M.getActiveActions | () → table | Returns all currently active actions (keyed by unique name). Caches result. |
M.upgradeAction | (action) → string|nil | Checks for deprecated/replaced actions, returns the upgraded name or nil if obsolete/inactive. |
M.actionToCommands | (actionName, actionCache?) → success, actionMap, ... | Converts an action definition into C++ binding parameters (actionMap, onChange/onDown/onUp commands, context, etc.). |
M.uniqueNameToName | (uniqueActionName, vehicleName) → string | Strips vehicle prefix from a mangled action name. |
M.nameToUniqueName | (actionName, vehicleName) → string | Adds vehicle prefix to prevent action name collisions (e.g. pickup__myAction). |
M.executeCommand | (evt, actionValue, vehicleId) → number | Executes an action command with the given value. Routes to vlua/elua/tlua/bvlua context. Returns 1 on success. |
M.triggerDown | (actionName) | Programmatically triggers a digital action press. |
M.triggerUp | (actionName) | Programmatically triggers a digital action release. |
M.triggerDownUp | (actionName) | Triggers a press followed by release. |
Action Definition Format (JSON)
{
"steering": {
"cat": "vehicle",
"ctx": "vlua",
"onChange": "input.event('steering', VALUE, FILTERTYPE, ANGLE, LOCKTYPE)",
"isCentered": true,
"desc": "ui.controls.steering"
}
}Command Contexts
| Context | Constant | Target |
|---|---|---|
vlua | COMMAND_CONTEXT_VLUA | Player vehicle Lua |
tlua | COMMAND_CONTEXT_TLUA | GE/top-level Lua (default) |
elua | COMMAND_CONTEXT_ELUA | Extension Lua |
bvlua | COMMAND_CONTEXT_BVLUA | Broadcast to all objects |
Action Maps
| Map | When Used |
|---|---|
Normal | Default gameplay actions |
Menu | Menu navigation actions (cat = "menu") |
VehicleCommon | Vehicle Lua context actions |
VehicleSpecific | Per-vehicle actions (from jbeam inputActions) |
MenuIndependent_* | Per-action menu-independent maps |
Hooks
| Function | Description |
|---|---|
M.onFirstUpdate | Clears action cache on first frame. |
M.onVehicleSwitched | Clears action cache (vehicle-specific actions may change). |
M.onFileChanged | Clears cache when action JSON files change. |
M.dependencies | Table. Required extensions: {'core_input_categories', 'core_input_deprecatedActions', 'tech_license'} |
M.menuActionMapNames | Table. Names of menu action maps. |
M.menuIndependentPrefix | String. Prefix for menu-independent actions ("MenuIndependent_"). |
Module State
| Variable | Type | Default |
|---|---|---|
dependencies | table | { "core_input_categories", "core_input_deprecat... |
menuActionMapNames | table | {} |
Usage Example
-- Get all active actions
local actions = core_input_actions.getActiveActions()
-- Check if an action exists
local action = core_input_actions.upgradeAction("steering")
-- Programmatically trigger an action
core_input_actions.triggerDownUp("reset_physics")
-- Execute an action command manually
local evt = { ctx = "vlua", onDown = "input.event('horn', 1)" }
core_input_actions.executeCommand(evt, 1, vehicleId)Key Internals
- Vehicle-specific actions are read from
vehicles/{name}/input_actions*.jsonand jbeaminputActions. - Actions are name-mangled with vehicle name prefix for uniqueness.
actionsEnabledfrom jbeam determines which vehicle actions areusablevsvehicle_specific_unusable.- The
menuIndependentPrefixis"MenuIndependent_".
See Also
- Input Action Filter - Related reference
- Input Bindings - Related reference
- Input Categories - Related reference
- Core Systems Guide - Guide
Input Action Filter
Blocks or allows specific input actions by name or group. Used to restrict player actions during missions, scenarios, and specific game states (e.g. disabling vehicle switching during a race).
Input Bindings
Manages input device bindings: reads default + custom bindings from disk, applies diffs, sends to the engine's ActionMap system, handles force feedback (FFB) configuration, device hot-plug, multiseat