Jump to content
Sign in to follow this  
IGG Jaypee

function call: halt other engine processes?

Recommended Posts

We are getting unexpected results in our logfiles when running the script below. This is just a testscript to help us understand the behaviour of our real project. We were hoping that "call _code;" would drop two identical numerical valuesinto the log file but as can be seen that did not happen.

_spawnCode =
{
    _code = 
    {
        diag_log str(val);
        _i=0;
        while {_i<9999} do 
        {
            _i=_i+1;
        };
        diag_log str(val);
    };
    sleep 0.0015;
    call _code;
};

val =0;
[] spawn _spawnCode;

while {val<50000} do
{
    val=val+1;
};

////////Logfile output//////////

20:51:34 "10000"
20:51:35 "27553"

 

references:

 

"Unlike scripts, functions halt all other game engine processes until the function has completed its instructions."

Share this post


Link to post
Share on other sites

If you call a function from a scheduled environment (a script running in an incorruptible environment), it will also run in such an environment, and therefore can be interrupted as well. Therefore, theoretically, when calling the function from 2 different spawned scripts, you might have both print val to the log before either of them resets val to 0.

 

If you call the script from something like the "on activation" field of a trigger, then it stops all other scripts when it starts running until it's done (although there is a loop iteration count limit, but I've never tested how that works out - You never really want these kids of scripts to run any extensive loops anyway).

Share this post


Link to post
Share on other sites

That page will have to go, just didn't have time or motivation to get rid of it. Added warning for now. 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×