Jump to content
Sign in to follow this  
twisted

pass marker to setTriggerStatements. possible?

Recommended Posts

_markernameE = "markerE" + (str _townCounter);
_MarkerE = CreateMarker [_markernameE, _townpos];
_MarkerE SetMarkerShape "ELLIPSE";
_MarkerE SetMarkerSize [_markersize ,_markersize];
_MarkerE SetMarkerColor "ColorRed";
_townCounter = _townCounter + 1;


_trg=createTrigger["EmptyDetector", _townpos];
_trg setTriggerArea[_markersize,_markersize,0,false];
_trg setTriggerActivation["WEST","PRESENT",false];
_trg setTriggerStatements["this", "[thisTrigger ,_MarkerE] execVM ""autospawn.sqf""", "hint 'no civilian near'"]; 

then in my other code i have

item = _this select 0;
_markerE = _this select 1;
_itempos = getpos _item;

_MarkerE SetMarkerColor "ColorBlue"; 

why does the marker reference i passed to the trigger not turn the trigger blue? it should?

Share this post


Link to post
Share on other sites
_trg setTriggerStatements["this", [color="#FF0000"]"[/color][thisTrigger ,_MarkerE] execVM ""autospawn.sqf""[color="#FF0000"]"[/color], "hint 'no civilian near'"];

_MarkerE isnt variable but part of the string

Share this post


Link to post
Share on other sites

Because the trigger statements are passed as strings to the trigger i believe that when the trigger fires (as it is no longer in the scope of the local variable _MarkerE) it has no idea what this value is.

You can format the line and compile it to insert the marker name rather than a variable holding the name.

Replace your current trigger statement line with this:-

call compile format ["_trg setTriggerStatements['this', '[thisTrigger ,%1] execVM ""autospawn.sqf""', 'hint ""no civilian near""']", str _MarkerE];

Share this post


Link to post
Share on other sites

Thanks Larrow. works perfectly. why it is so unintuitive i cannot say, but appreciate you having shown me the solution. :)

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  

×