addUserActionEventHandler: Difference between revisions
Lou Montana (talk | contribs) m (Text replacement - "\] +\[" to "] [") |
Lou Montana (talk | contribs) (Add _thisEvent, thanks to NikkoJT) |
||
Line 9: | Line 9: | ||
|descr= Adds a user action event handler to the current mission and returns its event handler index. | |descr= Adds a user action event handler to the current mission and returns its event handler index. | ||
|s1= [[addUserActionEventHandler]] [keyName, event, expression] | |s1= [[addUserActionEventHandler]] [keyName, event, expression] | ||
Line 15: | Line 16: | ||
|p2= event: [[String]] - event name - see [[Arma 3: Event Handlers#UserAction Event Handlers|UserAction Event Handlers]]. Can be one of: | |p2= event: [[String]] - event name - see [[Arma 3: Event Handlers#UserAction Event Handlers|UserAction Event Handlers]]. Can be one of: | ||
* "Activate" | * {{hl|"Activate"}} | ||
* "Deactivate" | * {{hl|"Deactivate"}} | ||
* "Analog" | * {{hl|"Analog"}} | ||
|p3= expression: [[Code]] - expression that will be executed in [[missionNamespace]] when event handler fires.<br> | |p3= expression: '''[[Code]]''' - expression that will be executed in [[missionNamespace]] when event handler fires.<br> | ||
The Event Handler index is available as {{hl|_thisEventHandler}} during Event Handler code execution. | The Event Handler index is available as {{hl|{{Link|Magic Variables#thisEvent|_thisEventHandler}}}} during Event Handler code execution.<br> | ||
{{ | The magic variable {{hl|{{Link|Magic Variables#thisEvent|_thisEvent}}}} is available in these event handlers but can only return one of these three values: | ||
* {{hl|"KeyActivateEH"}} | |||
* {{hl|"KeyDeactivateEH"}} | |||
* {{hl|"KeyAnalogEH"}} | |||
|r1= [[Number]] - the index of the currently added UserAction event handler is returned | |r1= [[Number]] - the index of the currently added UserAction event handler is returned |
Revision as of 15:42, 5 May 2025
Description
- Description:
- Adds a user action event handler to the current mission and returns its event handler index.
- Groups:
- Event Handlers
Syntax
- Syntax:
- addUserActionEventHandler [keyName, event, expression]
- Parameters:
- keyName: String - action key name - see inputAction/actions
- event: String - event name - see UserAction Event Handlers. Can be one of:
- "Activate"
- "Deactivate"
- "Analog"
- expression: Code - expression that will be executed in missionNamespace when event handler fires.
The Event Handler index is available as _thisEventHandler during Event Handler code execution.
The magic variable _thisEvent is available in these event handlers but can only return one of these three values:- "KeyActivateEH"
- "KeyDeactivateEH"
- "KeyAnalogEH"
- Return Value:
- Number - the index of the currently added UserAction event handler is returned
Examples
- Example 1:
- private _ehId = addUserActionEventHandler ["ReloadMagazine", "Activate", { systemChat "reloading!"; }];
Additional Information
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note