04-29-2010, 02:26 AM
Quote:Trigger condition is evaluated every 0.5 seconds in OFP, but it's still a good practice to not have super long conditions (like forEach'ing large arrays of units) because they block all other execution. For example, try this condition for a trigger:
a=[];while"count a<9999"do{a=a+[random(1000)]}; hint format["%1",{_x>500}count a]; time%1<.5
It will make the game freeze for a split second every time the condition is evaluated.
Or, if you really want to see some CPU lag, check out this failed attempt at a number-factoring .sqf function that I tried to make (I'll get it eventually!). It has to be named "factorthis."
Code:
private ["_number","_divisor","_possibfactor", "_factorsarray"];
_number = _this select 0;
_divisor = _number;
_factorsarray = [];
while "_divisor > 0" do
{
  _possibfactor = _number / _divisor;
  if ((_possibfactor mod 1) == 0) then
    {
      _nextfactors = [_possibfactor] call factorthis;
      if (count _nextfactors <= 2) then
        {
          _factorsarray = _factorsarray + [_possibfactor];
        };
    };
  _divisor = _divisor - 1;
};
_factorsarray
Clearly, my thinking went wrong somewhere. ;D
R. Kurtz "Koortz" Dmitriyev
My methods have become "unsound."
My methods have become "unsound."