Jump to content

Recommended Posts

How would I do an execVM from inside a trigger. This does not work

_trg = createTrigger ["EmptyDetector", getPos _casSpawn];
_trg setTriggerArea [20, 20, 10, false];
_trg setTriggerActivation ["CIV", "PRESENT", true];
_trg setTriggerStatements ["this", "execVM "mount.sqf";", "hint 'Test'"];

and also how do I mount the AI into the nearest vehicle as cargo when it is triggered.

Share this post


Link to post
Share on other sites

"execVM "mount.sqf";"

 

this bit needs  to be like this

 

"execVM 'mount.sqf';"

 

" " inside " " need to be ' ' 

  • Like 1

Share this post


Link to post
Share on other sites

I have change the code but it tell me undifined variable in expression

here it is

_trg = createTrigger ["EmptyDetector", getPos _casSpawn];
_trg setTriggerArea [20, 20, 10, false];
_trg setTriggerActivation ["CIV", "PRESENT", true];
_trg setTriggerStatements ["this", "null = [_casSpawn,_casPos,_casGroup] execVM 'mount.sqf';", "hint 'Test'"];

 

Share this post


Link to post
Share on other sites
1 hour ago, felipechapmanfromm said:

_casSpawn,_casPos,_casGroup

These variables are undefined within the scope of your triggers activation code. You have to remember that the STRING representing your triggers activation code is deferred to run at some point in the future (when the trigger is activated) and as such knows nothing about any local variables that where present at the time you set the triggers activation code.

Share this post


Link to post
Share on other sites
18 hours ago, Chuc said:

"execVM "mount.sqf";"

 

this bit needs  to be like this

 

"execVM 'mount.sqf';"

 

" " inside " " need to be ' ' 

You can also do:

"[] execVM ""test.sqf"";"

 

Share this post


Link to post
Share on other sites
Just now, HazJ said:

You can also do:


"[] execVM ""test.sqf"";"

 

yeah it was late and i didnt want to add that way. The way i wrote it would of look weird

Share this post


Link to post
Share on other sites

Yeah, I know. Most people use the way you said. I prefer double " that's all. Just thought I'd share the other way.

Share this post


Link to post
Share on other sites

i use them like this

 

hint parseText format['<t size=""1.10"" font=""PuristaMedium"" color=""#13F03C"">You are out of contamination</t>'];

 

Looks nicer i think

Share this post


Link to post
Share on other sites

I've fixed the variable problem and the execVM but now i need to know how to pull variables from the mission editor, I have made a heli that  has the var name heli1, how do i get heli1 into my sqf files

Share this post


Link to post
Share on other sites
23 minutes ago, felipechapmanfromm said:

how to pull variables from the mission editor, I have made a heli that  has the var name heli1, how do i get heli1 into my sqf files

Just use heli1 giving it a variable name automatically creates a global variable of the same name that is a reference to your object.

Share this post


Link to post
Share on other sites
23 hours ago, felipechapmanfromm said:

I have change the code but it tell me undifined variable in expression


_trg = createTrigger ["EmptyDetector", getPos _casSpawn];
_trg setTriggerArea [20, 20, 10, false];
_trg setTriggerActivation ["CIV", "PRESENT", true];
_trg setTriggerStatements ["this", "null = [_casSpawn,_casPos,_casGroup] execVM 'mount.sqf';", "hint 'Test'"];

 

 

Just for the record, if a trigger is created in a script and local variables need to be used in the activation call of the trigger, all forms of parsing variables into strings can be used:

 

private["_casSpawn","_casPos","_casGroup","_trg"];
// Setting _casSpawn,_casPos,_casGroup to some values
_trg = createTrigger ["EmptyDetector", getPos _casSpawn];
_trg setTriggerArea [20, 20, 10, false];
_trg setTriggerActivation ["CIV", "PRESENT", true];
_trg setTriggerStatements ["this", format ["null = [%1,%2,%3] execVM 'mount.sqf';",_casSpawn,_casPos,_casGroup], "hint 'Test'"];

This will parse the variables into the string and it will become a static expression like "null = [someObject,[2312,54234,234],SomeGroup-1-2-West] execVM 'mount.sqf';" that can be called uncoupled from the script creating the trigger.

In some cases, the str command needs to be added to the parameters of format to have the variables added correctly (needed for string to have correct escaping of quotes).

 

When debugging this, it is good to make your called script (mount.sqf) print all parameters and their type into the rpt or chat to check if everything worked as expected.

  • Like 2

Share this post


Link to post
Share on other sites
8 hours ago, NeoArmageddon said:

 

Just for the record, if a trigger is created in a script and local variables need to be used in the activation call of the trigger, all forms of parsing variables into strings can be used:

 

You know, sometimes my own ability to overlook the obvious is just astounding. Your post solved a big problem I was having back in A2 - I was on the right track, but was consistently losing sight of the actual issue. Too late to fix that old problem, but you just made something "click" for me. Thanks, I love it when that happens! 

  • Like 1

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

×