Advertisement
Brick

A3 Custom funcs

Aug 17th, 2016
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 1.21 KB | None | 0 0
  1. span class="re5"> replaceInString =
  2. {
  3.     if !(_this isEqualTypeArray ["", "", ""]) exitWith
  4.     {
  5.         "";
  6.     };
  7.  
  8.     _string = param[0];
  9.     _from   = param[1];
  10.     _to     = param[2];
  11.  
  12.     if (_from isEqualTo "") exitWith
  13.     {
  14.         _string;
  15.     };
  16.  
  17.     _parts = [ ];
  18.  
  19.     while { true } do
  20.     {
  21.         _find = _string find _from;
  22.  
  23.         if (_find == -1) exitWith
  24.         {
  25.             _parts pushBack _string;
  26.         };
  27.  
  28.         _parts pushBack (_string select [0, _find]);
  29.  
  30.         _string = _string select [_find + count _from];
  31.     };
  32.  
  33.     _parts joinString _to;
  34. };
  35.  
  36. compileConst =
  37. {
  38.     _convertToString =
  39.     {
  40.         if (_this isEqualType [ ]) exitWith
  41.         {
  42.             _this apply { _x call _convertToString };
  43.         };
  44.  
  45.         if (_this isEqualType "") exitWith
  46.         {
  47.             _this splitString '"' joinString '""';
  48.         };
  49.  
  50.         if (_this isEqualTypeAny [false, 0, { }]) exitWith
  51.         {
  52.             _this;
  53.         };
  54.  
  55.         "";
  56.     };
  57.  
  58.     compileFinal str (_this call _convertToString);
  59. };
  60.  
  61. compileFunc =
  62. {
  63.     if !(_this isEqualType { }) exitWith { };
  64.  
  65.     _string = str _this;
  66.  
  67.     compileFinal (_string select [1, count _string - 2]);
  68. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement