Jump to content
Sign in to follow this  
DaveP

Passing local variable through trigger activation, not working?

Recommended Posts

As the title suggests, I'm attempting to pass the name of a unit through a trigger's activation, which was originally spawned by the script. And failing. See below:

_myman = _this select 0
//selecting the bloke

_trg = "trigger" + _myman
//as I believe the trigger needs to have a global variable for a name, correct?

_trg = createTrigger["EmptyDetector",getPos _myman]
_trg setTriggerArea[.5,2,0,false]
_trg setTriggerActivation["CIV","PRESENT",true]
_trg setTriggerStatements["this", "[_myman,(thislist select 0)] exec 'continueon.sqs'", ""]
//this is where I imagine the problem is

_trg attachTo [_myman,[0,1,0]]

continueon.sqs starts with a simple

_myman = _this select 0

and continues on from there, however it doesn't seem to catch the unit name, any ideas why? Is it because setTriggerStatements uses strings?

Share this post


Link to post
Share on other sites

This is what you set your triggers on activation to:

[_myman,(thislist select 0)] exec 'continueon.sqs'

It is the equivalent of writing that exact same piece of code into a triggers on act. However, a triggers on act is in some ways similar to a separate scripts. It does not know what _myman is. Triggers only work with global names.

You need to get it to say the actual name of the unit where it say's _myman instead. If you need the unit and not just the name you will need a different approach.

To do this you can use the format statement:

_triggerOnAct = format "[%1,(thislist select 0)] exec 'continueon.sqs'", name _myman];

then put it in like this:

_trg setTriggerStatements["this", _triggerOnAct, ""]

Now will be the equivalent of:

["SomeName",(thislist select 0)] exec 'continueon.sqs'

However, you script seems to conflict with it's uses of _myman:

_trg = "trigger" + _myman

Would suggest that _myman is a string not an object.

_trg attachTo [_myman,[0,1,0]]

Would suggest that _myman is a object and not a string.

Oh btw, you need a semicolon at the end of all statements.

Share this post


Link to post
Share on other sites

I get you on the formatting, good call

The usage of _myman in the declaration of _trg was to give it a variable name that would be distinct to that unit and easily referred to

I'm SQS scripting because I'm an old OFP scripting fart that doesn't stay up to date

Also, for completion's sake, your line should read

_triggerOnAct = format ["[%1,(thislist select 0)] exec 'continueon.sqs'", name _myman];

Edited by DaveP

Share this post


Link to post
Share on other sites

_trg = "trigger" + _myman

That doesn't do anything as the variable _trg is overwritten right after with the trigger object.

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  

×