-
Notifications
You must be signed in to change notification settings - Fork 150
CBA_fnc_addBISEventHandler
commy2 edited this page May 17, 2016
·
2 revisions
This is a framework/wrapper to add event handlers with arguments. The event handlers ID will also be passed as a special variable.
Events are added via CBA_fnc_addBISEventHandler
.
The ID returned by that function can be used to remove the event via removeEventHandler
, displayRemoveEventHandler
, ctrlRemoveEventHandler
or removeMissionEventHandler
respectively. The events can also be removed from inside the event by utilizing the special variable _thisId
.
Parameters:
-
_object
: Thing to attach event handler to. Can be a <OBJECT>, <DISPLAY> or <CONTROL>.missionNamespace
is used to add mission events. -
_type
- The event handler type. <STRING> -
_function
- The function to execute when the event occurs. <CODE> -
_arguments
- Arguments to pass to event handler. They will appear as_thisArgs
special variable.
-
_this
: Default event handler arguments. -
_thisType
: The type of the event (e.g."Fired"
,"Draw3D"
,"keyDown"
) -
_thisId
: The id used to remove the event (e.g. viactrlRemoveEventHandler
). -
_thisArgs
: - Additional arguments passed when the event handler was added. -
_thisFnc
: - A copy of the function. <CODE>
- A one time
reloaded
event handler (prints "bananas" once after first reload):
[player, "reloaded", {
systemChat _thisArgs;
player removeEventHandler [_thisType, _thisID];
}, "bananas"] call CBA_fnc_addBISEventHandler;
- Print text once after 300 frames:
[missionNamespace, "EachFrame", {
if (diag_frameno < _thisArgs) exitWith {};
systemChat "hello world";
removeMissionEventHandler [_thisType, _thisID];
}, diag_frameno + 300] call CBA_fnc_addBISEventHandler;