BIS fnc addStackedEventHandler – Talk

From Bohemia Interactive Community
Revision as of 03:04, 9 December 2014 by DreadedEntity (talk | contribs)
Jump to navigation Jump to search

Not being able to override default engine behavior was really bumming me out, so I took a look at BIS_fnc_executeStackedEventHandler. By adding 2 variables, I was able to make the function perform as intended (as I see it). Please push this fix to the next hotfix, BIS!

/* Author: Nelson Duarte Edit by: Dread (in bold)

Description: This function executes the stacked items, should not be called independently

Parameter(s): _this select 0: STRING - The onXxx event handler

Returns: BOOL - True if executed code returns true False if executed code returns anything else

  • /Parameters

private ["_event"]; _event = [_this, 0, "", [""]] call BIS_fnc_param;

//Mission namespace id private "_namespaceId"; _namespaceId = "BIS_stackedEventHandlers_";

//Mission namespace event private "_namespaceEvent"; _namespaceEvent = _namespaceId + _event;

//The data private "_data"; _data = missionNameSpace getVariable [_namespaceEvent, []];

//Add 2 new variables and define private ["_return","_trash"]; _return = false; _trash = false;

//Process data { //Data item parameters private ["_code", "_arguments"]; _code = [_x, 2, "", [{}, ""]] call BIS_fnc_param; _arguments = [_x, 3, []] call BIS_fnc_param;

if (typeName _code != typeName "") then { //Execute code _trash = _arguments call _code; //call can return, why waste? } else { //Execute function _trash = _arguments call (call compile _code); //not really sure what's happening here. 2 calls? }; if (typeName _trash == "BOOL") then { if (_trash) then { _return = true; }; }; } forEach _data;

//Return _return; Can't get this post formatted correctly. I'm just going to leave it like it is. - DreadedEntity