OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: ModestNovice on 10 Dec 2008, 04:55:42

Title: call vs. execVM
Post by: ModestNovice on 10 Dec 2008, 04:55:42
Hi guys, quick question.

If I'm dealing with a large sleep number, is it 'better' to execVM a script, or can I use in function?

-> script:
Code: [Select]
_amount = _this select 0;

Sleep _amount;

Hint "Done.";
;


-> function:
Code: [Select]

_MyFantasticFunction =
{
_amount = _this select 0;

[] spawn
{
Sleep _amount;

Hint "Done.";
};
};


I tested both, and they worked exactly the same, but I'm just wondering performance wise if either works better then the other.
Title: Re: call vs. execVM
Post by: Mandoble on 10 Dec 2008, 09:51:36
If you are going to execute that code many times, then it might be better to compile it once and then use call or spawn for every execution as execVM compiles the code each time you execute the script.
Title: Re: call vs. execVM
Post by: Ext3rmin4tor on 10 Dec 2008, 11:35:10
Besides don't use "call" when you have many sleep statements since the "call" command stops the execution of the calling script until the function ends, so you should use "spawn" instead of "call" (unless you made a function which returns a value, in that case the only possible command is "call" if you want to have access to the returned value itself). You can find further info in this topic:

http://www.ofpec.com/forum/index.php?topic=32627.0
Title: Re: call vs. execVM
Post by: ModestNovice on 10 Dec 2008, 22:00:25
yeh I need it to return or do something at the end.

Thanks for the help you two.