Skip to content

InputActionMap

Extends EngineObject.

Every action the player can bind, where each works (its contexts) and what it is bound to. Contexts are names the game chooses (world, on_foot, vehicle, menu); situations say which are active together, so two actions that can never be active at once may share an input. A InputActionRouter turns the player's input into these actions.

Create one with InputActionMap.new().

Methods

add_situation

function add_situation(self, contexts: { string }): ()

Says that these contexts are active together (a situation). Without any, two actions clash when they share a context.

add_action

function add_action(self, id: string, contexts: { string }, defaults: { string }, analog: boolean?, help: string?): ()

Adds an action, bound to defaults (binding texts: see Binding). An analog action is read by strength; the others fire.

has_action

function has_action(self, id: string): boolean

get_actions

function get_actions(self): { string }

The ids of the actions, in the order they were added.

get_help

function get_help(self, id: string): string

What an action is for, as it was added.

get_contexts

function get_contexts(self, id: string): { string }

is_analog

function is_analog(self, id: string): boolean

contexts_overlap

function contexts_overlap(self, a: { string }, b: { string }): boolean

True when an action of a and one of b can be active at the same time.

set_bindings

function set_bindings(self, id: string, bindings: { string }): ()

Rebinds an action. Throws (a script error) on a binding that does not read.

get_bindings

function get_bindings(self, id: string): { string }

get_defaults

function get_defaults(self, id: string): { string }

reset

function reset(self, id: string): ()

reset_all

function reset_all(self): ()

Puts every defined action back to its defaults. Saved bindings of actions that are not defined (yet) are kept.

get_conflicts

function get_conflicts(self, id: string, binding: string): { string }

The actions that would clash if id were bound to this text.

get_all_conflicts

function get_all_conflicts(self): { string }

Every clash as a line of three tab-separated fields: the action, the other action and the binding.

save_text

function save_text(self): string

Save as text, one line per action: lights = Hold L | Joy RB (an action with no binding has nothing after the equals sign).

load_text

function load_text(self, text: string): { string }

Applies SaveText's text; returns what could not be applied, as Load does.

Functions

normalize_binding

InputActionMap.normalize_binding: (text: string) -> string

The binding text as it would be saved: the trigger, the modifiers and the input spelled the way this class writes them. Throws (a script error) on text that does not read.

binding_error

InputActionMap.binding_error: (text: string) -> string

Why a binding text does not read, or an empty string when it does.

parse_binding

InputActionMap.parse_binding: (text: string) -> (string, { Modifiers }, Trigger)

A binding's parts: the input, its modifiers, its trigger. Throws (a script error) on text that does not read.