BIS fnc addScriptedEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(syntax, parameters, and examples, see also)
Line 24: Line 24:
____________________________________________________________________________________________
____________________________________________________________________________________________


| <!-- [] call [[BIS_fnc_addScriptedEventHandler]]; --> |= Syntax
| [missionNamespace,"",""] call [[BIS_fnc_addScriptedEventHandler]]; |= Syntax


|p1= |= Parameter 1
|p1=<b>NAMESPACE, OBJECT, GROUP LOCATION or BOOLEAN</b> - namespace in which handler is saved|
p2= <b>STRING</b> - handler name|
p3=<b>CODE or STRING </b>- code executed upon calling |= Parameter 1


| |= Return value
 
object: Object
[type, command]: Array
type: String - Event Handler type
command: Code or String - code that should be executed once the event occurs, by default executed in missionNamespace
 
 
 
| Number - The index of the currently added event handler is returned. Indices start at 0 for each unit and increment with each added event handler.|= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________
Examples:


|x1= <code></code> |=  
|x1= <code> [missionNamespace,"event",{hint "Hello World";}] call bis_fnc_addScriptedEventhandler; </code> |=
 
|x2= stacking code:<code>[missionNamespace,"event",{STRING "Hello World";}] call BIS_fnc_addScriptedEventhandler;
[missionNamespace,"event",{hint STRING;}] call BIS_fnc_addScriptedEventhandler;
 
[missionNamespace,"event",[]] call BIS_fnc_callScriptedEventHandler;
</code>  will show "Hello World" on screen. |=
 
|x3= <code> [true,"event",{hint "Hello World";}] call bis_fnc_addScriptedEventhandler; </code>
Boolean will default to misionNameSpace |=  
____________________________________________________________________________________________
____________________________________________________________________________________________
 
| [[BIS_fnc_callScriptedEventHandler]] [[BIS_fnc_removeScriptedEventHandler]]  [[BIS_fnc_removeAllScriptedEventHandlers]] |= See also
| [[BIS_fnc_callScriptedEventHandler]] |= See also


}}
}}
Line 49: Line 68:
[[Category:Functions|{{uc:addScriptedEventHandler}}]]
[[Category:Functions|{{uc:addScriptedEventHandler}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:addScriptedEventHandler}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:addScriptedEventHandler}}]]
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on May 15, 2016 - 19:13 (UTC)</dd>
<dt class="note">[[User:RageBone|RageBone]]</dt>
<dd class="note">
Example:<br>
<code>
_index = [missionNamespace,"event",{someCode = "Hello World";}] call bis_fnc_addScriptedEventhandler; <br> //_index == 0<br>
_index = [missionNamespace,"event","hint someCode;"}] call bis_fnc_addScriptedEventhandler; <br>// _index == 1<br>
//executing will hint "hello world".<br>
[missionNamespace,"event",[]] call bis_fnc_callScriptedEventHandler;
</code><br>
Note that this is capable of stacking code, the order of stacking code matters!
</dd>
</dl>
<!-- DISCONTINUE Notes -->
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on May 18, 2016 - 18:38 (UTC)</dd>
<dt class="note">[[User:RageBone|RageBone]]</dt>
<dd class="note">
the first parameter can also be Boolean, preferably "true".<br>
it then defaults to the missionNamespace as the place where it stores the event code.<br><br>
the code gets stored in the variable: <code>
_handlerName = "BIS_fnc_addScriptedEventHandler_" +  _handlerName;<br>
// some other code for stacking the event-code. (_handlers) <br>
_namespace setvariable [_handlerName,_handlers];<br>
</code><br><br>
location of the function:<br>
Addons\functions_f\misc
</dd>
</dl>
<!-- DISCONTINUE Notes -->

Revision as of 21:18, 18 May 2016


Hover & click on the images for description

Description

Description:
/*

	Description:
	Add scripted event handler

	Parameter(s):
		0: NAMESPACE, OBJECT, GROUP or LOCATION - namespace in which handler is saved
		1: STRING - handler name
		2: CODE or STRING - code executed upon calling

	Returns:
	NUMBER - handler ID
*/
(Placeholder description extracted from the function header by BIS_fnc_exportFunctionsToWiki)
Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
[missionNamespace,"",""] call BIS_fnc_addScriptedEventHandler;
Parameters:
NAMESPACE, OBJECT, GROUP LOCATION or BOOLEAN - namespace in which handler is saved
STRING - handler name
CODE or STRING - code executed upon calling
Return Value:
Number - The index of the currently added event handler is returned. Indices start at 0 for each unit and increment with each added event handler.

Examples

Example 1:
[missionNamespace,"event",{hint "Hello World";}] call bis_fnc_addScriptedEventhandler;
Example 2:
stacking code:[missionNamespace,"event",{STRING "Hello World";}] call BIS_fnc_addScriptedEventhandler; [missionNamespace,"event",{hint STRING;}] call BIS_fnc_addScriptedEventhandler; [missionNamespace,"event",[]] call BIS_fnc_callScriptedEventHandler; will show "Hello World" on screen.
Example 3:
[true,"event",{hint "Hello World";}] call bis_fnc_addScriptedEventhandler; Boolean will default to misionNameSpace

Additional Information

See also:
BIS_fnc_callScriptedEventHandler BIS_fnc_removeScriptedEventHandler BIS_fnc_removeAllScriptedEventHandlers

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

Notes

Bottom Section