ACE3/addons/common/functions/fnc_toBitmask.sqf

28 lines
425 B
Plaintext
Raw Permalink Normal View History

#include "..\script_component.hpp"
/*
* Author: commy2
* Convert an array of booleans into a number.
*
2015-09-17 16:25:02 +00:00
* Arguments:
* 0: Boolean <BOOL>
* 1: Boolean <BOOL>
* 2: Boolean <BOOL>
* ...
*
2015-09-17 16:25:02 +00:00
* Return Value:
2015-09-19 22:55:58 +00:00
* Bitmask <NUMBER>
2015-09-17 16:25:02 +00:00
*
* Example:
* [[true, false]] call ace_common_fnc_toBitmask
*
2015-09-17 16:25:02 +00:00
* Public: Yes
*/
private _result = 0;
2015-09-19 22:55:58 +00:00
{
2015-05-14 18:06:06 +00:00
if (_x) then {_result = _result + 2 ^ _forEachIndex};
2015-09-20 13:52:40 +00:00
} forEach _this;
_result