OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Terox on 01 Mar 2007, 17:43:29

Title: using execVM in the activation field of a waypoint
Post by: Terox on 01 Mar 2007, 17:43:29
[group this, array] execVM "myscript.sqf"


can't get a waypoint to accept this code in it's activation field
however it will happily accept

[group this, array] exec "myscript.sqs"

is this a feature/bug or am i doing something wrong with the execVM
Title: Re: using execVM in the activation field of a waypoint
Post by: h- on 01 Mar 2007, 17:48:01
sqf is still considered to be a function by the game instead of regular script (or something like that), so you need to use either:
Code: [Select]
foo=[group this, array] execVM "myscript.sqf"or
Code: [Select]
call {[group this, array] execVM "myscript.sqf"}
Personally I prefer the latter..
Title: Re: using execVM in the activation field of a waypoint
Post by: Terox on 04 Mar 2007, 23:17:04
thx H, that did it
Title: Re: using execVM in the activation field of a waypoint
Post by: Killswitch on 06 Mar 2007, 15:48:55
It's a feature of the intended kind - in other words, that's how it's supposed to work.

The reason why the execVM (http://community.bistudio.com/wiki/execVM) attempt fails and exec (http://community.bistudio.com/wiki/exec) works is that the former is a command that returns a value (a script handle (http://community.bistudio.com/wiki/Script_%28Handle%29)) whereas exec returns nothing (http://community.bistudio.com/wiki/Nothing).

h- showed two ways of handling it - you either make use of the return value from execVM or you do a call "trick" to throw it away.
Title: Re: using execVM in the activation field of a waypoint
Post by: h- on 06 Mar 2007, 23:04:03
I stand educated :)

Is there some other use for the script handle than the use with the command terminate (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=t#terminate)?
Title: Re: using execVM in the activation field of a waypoint
Post by: Mandoble on 07 Mar 2007, 00:33:16
Yep, you may check if one script is finished using its handler for scriptDone command.

Code: [Select]
_script1=[group this, array] execVM "myscript.sqf";
waitUntil {scriptDone _script1;};
hint "MyScript.sqf finished";

Title: Re: using execVM in the activation field of a waypoint
Post by: h- on 07 Mar 2007, 07:52:21
Right, knew about that command but completely forgot it..
Way too many new commands to make sense out of.. :P