Jump to content
Sign in to follow this  
stalkarn

Passing trigger or variable to addaction script

Recommended Posts

Hello!

I have a "hold" waypoint and whant it to release when a sertain condition is met. I also have an object with an "addaction" command attached to it. When the addaction is activated I want the waypoint to continue.

First I tried to use a trigger that had the condition set to false. Then I passed the trigger to the addaction command and changed the condition with a script. That didn't work.

Then I put myVariable = true in the condition field of the trigger and tried to pass the variable to the addaction command. That didn't work either.

How can I pass a variable to the addaction command (and make it affect a trigger)? That must be the easiest way.

In the editor:

evidence1 = evi1 addaction ["Collect evidence","evidence.sqf", ["conv_move"]];

In evidence.sqf

First try: Here the conv_move is a trigger named conv_move

grp = (_this select 3) select 0;
_trg setTriggerStatements["true","",""]; 

Second try: Here conv_move is a variable decleared in the triggers condition (conv_move = true).

grp = (_this select 3) select 0;
grp = true;

Dont mind the variable name "grp". It's from a third atempt....

Share this post


Link to post
Share on other sites

The part in red is the Array that will get passed to the script i.e.(evidence.sqf).

evidence1 = evi1 addaction ["Collect evidence","evidence.sqf", [color=#ff0000][1,2,3][/color]];

in the trigger condition put this:

[color=#FF0000]conv_move[/color]

in evidence.sqf :


// _this is the internal refrence to the array that we passed to the script. We can select items out of that array just like we would any other array. ie..(_this select _index)
_passedarray = _this select 3;

_myfirstvar = _passedarray select 0;

_mysecondvar = _passedarray select 1;

_mythirdvar = _passedarray select 2;

// Do what ever you need to here use the var

if (_myfirstvar == 1) then { [color=#FF0000]conv_move = true; publicVariable "[/color][color=#FF0000]conv_move";};
[/color]

The only thing else you need to do is define the conv_move variable as false in the init.sqf so you do not get an undefined variable error.

Edited by Riouken

Share this post


Link to post
Share on other sites

Thanks alot man! Defineing the variable in init.sqf did it :-)

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  

×