Jump to content
Sign in to follow this  
yacobm8

cant get function to create a trigger

Recommended Posts

So its my first time making a function. I have this in my init.sqf

myFunction = compile preprocessFileLineNumbers "makeTrigger.sqf";

makeTrigger.sqf

//create trigger around ai to detect whenhelicopter has landed.
_ai = _this;

_trigger = createTrigger["EmptyDetector",getPos _ai];
_trigger setTriggerArea [40, 40, 0, false];
_trigger setTriggerActivation ["WEST", "PRESENT", true];
_trigger setTriggerStatements ["(getPos helicopter select 2) < 4 && speed helicopter < 5 && (player distance _ai) < 40","_ai assignAsCargo helicopter; [_ai] orderGetIn true;",""];
_trigger;

now in my helicopters init i have a getIn event handler that then runs my script named waypoint.sqf. waypoint.sqf looks like this.

result = peter call myFunction; //note: peter is the name of the ai in the editor

The problem is that the trigger does not return to the waypoint.sqf script. I thought it would do because the last statement in the function is _trigger; which means that it should return the trigger right?

If you can't help me fix this then could you please explain how you would go about returning a trigger using a function?

also i checked my rpt log and there were no errors with the code.

Share this post


Link to post
Share on other sites

Use the format command to put _ai into the trigger statement string. You can't write local variables like that - It's in a different scope.

Edited by Fight9

Share this post


Link to post
Share on other sites

thanks flight9 that worked just like it should do now and i'll be sure to remember it in the future :)

Share this post


Link to post
Share on other sites

I'm glad you worked it out.

Truth be told, I'm glad you figured it out without me having write the exact code. It means you are learning.

Good shit

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  

×