Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // easy examples with a numeric array
- _data = [1,2,3,4,5,6,7,8,9];
- // filter
- _fnc = { _this >= 5 };
- [_data, _fnc] call AEX_filter; // [5,6,7,8,9]
- [_data, { _this < 4 }] call AEX_filter; // [1,2,3]
- [_data, { _this > 2 and _this < 8 }] call AEX_filter; // [3,4,5,6,7]
- [_data, { _this mod 2 == 0 }] call AEX_filter; // [2,4,6,8]
- // map
- [_data, { _this * 2 }] call AEX_map; // [2,4,6,8,10,12,14,16,18]
- [_data, { str _this }] call AEX_map; // ["1","2","3","4","5","6","7","8","9"]
- // reduce
- [_data, { (_this select 0) + (_this select 1) }] call AEX_reduce; // 45
- // combination of filter and reduce
- [[_data, { _this <= 5 }] call AEX_filter, { (_this select 0) * (_this select 1) }] call AEX_reduce; // 120
- // real ArmA examples
- // vehicles with at least 10% damage are mapped to an data array like [vehicle type, position, damage]
- _vehicles = [vehicles, { damage _this > .1 }] call AEX_filter;
- // [209f6080# 1056396: ah6x.p3d REMOTE,248de080# 1055939: hmmwv.p3d REMOTE]
- _vehicleData = [_vehicles, { [typeOf _this, position _this, damage _this] }] call AEX_map;
- // [["AH6X_DZ",[10473.1,8864.83,0.0306244],0.334646],["HMMWV_DZ",[11219.5,12499.5,-0.0309296],0.204724]]
- // list of player names and distance within 100m of the player who own a toolbox
- _nearEntities = player nearEntities 100;
- _players = [_nearEntities, { isPlayer _this and "ItemToolbox" in items _this }] call AEX_filter;
- _playerData = [_players, { [name _this, player distance _this] }] call AEX_map;
- // [["Player 1",0],["Player 2",68.1549],["Player 3",13.565]]
- // overall damage of all units
- [allUnits, { (_this select 0) + damage (_this select 1) }, 0] call AEX_reduce; // 2.457
Advertisement
Add Comment
Please, Sign In to add comment