Guest User

Untitled

a guest
Aug 5th, 2021
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 0.82 KB | None | 0 0
  1. /*
  2. Deletes odd or even indexes in an array and outputs the result to the var ThanosResults
  3.  
  4. Example: [_array1,"odd"] call func_thanosarray; _array1 = ThanosResults
  5. to get ["1","3"] from ["1","2","3","4"]
  6.  
  7.  
  8. Defaults to even if unspecified
  9.  
  10. Author: Phpminor
  11. */
  12. private["_worker","_helper","_output","_thanos"];
  13. _array = _this select 0 select 0;
  14. _worker = [];
  15. _worker append _array;
  16. _helper = [];
  17. _helper append _worker;
  18. _output = [];
  19. _thanos = _this select 0 select 1;
  20. _arraysize = count _array;
  21. _snapsneeded = _arraysize*0.5;
  22. ran = 0;
  23. ThanosResults = [];
  24.  
  25. {
  26. _odd = _foreachindex+0.6;
  27. _even = _foreachindex;
  28. if (_thanos == "odd") then {snap = _odd} else {snap = _even};
  29. if (ran == _snapsneeded) exitwith {_output append _helper;ThanosResults = _output;};
  30. ran = ran+1;
  31. _helper deleteat snap;
  32. }foreach _array;
  33.  
Advertisement
Add Comment
Please, Sign In to add comment