IGG Jaypee 10 Posted June 3, 2016 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: https://community.bistudio.com/wiki/Function#Call "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
galzohar 31 Posted June 3, 2016 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
killzone_kid 1326 Posted June 3, 2016 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
IGG Jaypee 10 Posted June 4, 2016 Cool Galzohar, thanks for the reply. That cleared things up. Share this post Link to post Share on other sites