ACE3/addons/common/functions/fnc_map.sqf
2015-05-14 20:06:06 +02:00

32 lines
685 B
Plaintext

/*
* Author: KoffeinFlummi, commy2
*
* Applies given code to every element in an array, LIKE SOMETHING SQF SHOULD HAVE BY DEFAULT.
*
* Arguments:
* 0: Array to be thingied.
* 1: Code to be applied to every element.
*
* Return Value:
* Final array
*
* Usage:
* [["2", "gobblecock", "25"], {parseNumber _this}] call FUNC(map) ==> [2, 0, 25]
*/
#include "script_component.hpp"
private ["_array", "_code"];
_array = + _this select 0;
_code = _this select 1;
if (isNil "_array") exitWith {
diag_log text format ["[ACE] ERROR: No array for function map in %1", _fnc_scriptNameParent];
[]
};
{
_array set [_forEachIndex, _x call _code];
} forEach _array;
_array