Blackheart_Six   284 Posted February 16, 2019 Good Day Everyone,  Let me preface my comments with I am not a software guy, I am a hardware guy, if you know what mean.  Problem Statement: I am trying to loop a single task, using a script. Lines 7 and Line 8 run, but doesn't show the task as "succeeded", it launches the task instantaneously. I imagine this is due to the fact it's part of the "CreateTrigger" block of code.  Goal: The current code does what I want as far as functionality, but runs too fast. I want line 7 to run, and show "Task Succeeded" message, then wait a few seconds and rerun the script from line 1. I've tried several different ways to pause between line 7 and line 8, using sleep, if....then, or waitUntil, etc. etc.  I am sure it is a matter of syntax, and something I am not doing correctly. Any help would be appreciated, and thanks in advance. And of course I've search the forums extensively, and tried different solutions.  _towns = nearestLocations [[15000,15000,5], ["NameCity","NameVillage"], 15000]; _RandomTownPosition = position (_towns select (floor(random (count _towns)))); _rndmTask = [blufor,"task_1",["Conduct a movement to contact mission. GRIDS reports possible enemy position","Movement to Contact"],_RandomTownPosition,true,0,true,"ATTACK",true] call BIS_fnc_taskCreate; _Trigger1 = createTrigger ["EmptyDetector",_RandomTownPosition]; _Trigger1 setTriggerArea [100,100,0,false]; _Trigger1 setTriggerActivation ["WEST","PRESENT",true]; _Trigger1 setTriggerStatements ["this","[""task_1"",""SUCCEEDED"",TRUE] call BIS_fnc_taskSetState",""]; _Trigger1 setTriggerStatements ["this","[]execVM 'Task_1.sqf'",""];   Share this post Link to post Share on other sites
pierremgi   4934 Posted February 16, 2019 Why do you have two following setTriggerStatements for the same trigger ?? Share this post Link to post Share on other sites
Blackheart_Six   284 Posted February 16, 2019 Hi Pierremgi,  That is my problem, I think..... 🙂  I've tried a single setTriggerStatements...  _Trigger1 setTriggerStatements ["this","[""task_1"",""SUCCEEDED";[]exec'task_1';",TRUE] call BIS_fnc_taskSetState",""];  so far, the only way I can get the script "task_1.sqf" to run after line 8, is creating a second setTriggerStatements.  Of course I don't know how to loop the code properly to start with. I've been reading the biki's, kk's page, just can't figure out how to loop back to the top.  GOTO LINE 1;        Share this post Link to post Share on other sites
pierremgi   4934 Posted February 16, 2019 No, for better visibility, just execVM an sqf (or spawn a code) in your trigger statement, then do what you want in this code. you can waituntil the task is succeeded then continue, loop or else. I'm not sure to understand all your stuff. some thing like [] spawn {  while {true} do {    createTask here;    watUntil { this task is succeeded};    sleep 10;   } } but I'm not sure why you stack the same task always and always. You can "rearm" the trigger as well, if needed. Share this post Link to post Share on other sites
Blackheart_Six   284 Posted February 16, 2019 Pierremgi thanks, I'll give a go. Thanks for the input. Share this post Link to post Share on other sites
Blackheart_Six   284 Posted February 16, 2019 Got it!  Thanks Pierre, I understand the while do syntax a lot better. That was a BIG help.  The reason I am looping the same task is this a simple 4 man COOP, Movement to Contact (kill everything), wash, rinse repeat.  [] spawn { while {true} do { sleep 5; _towns = nearestLocations [[15000,15000,5], ["NameCity","NameVillage"], 15000]; _RandomTownPosition = position (_towns select ((random (count _towns)))); [true,"task_1",["Conduct a movement to contact mission. GRIDS reports possible enemy position","Movement to Contact"],_RandomTownPosition,true,0,true,"ATTACK",true] call BIS_fnc_taskCreate; _Trigger1 = createTrigger ["EmptyDetector",_RandomTownPosition]; _Trigger1 setTriggerArea [50,50,0,false]; _Trigger1 setTriggerActivation ["WEST SIEZED","PRESENT",true]; _Trigger1 setTriggerStatements ["this","['task_1','SUCCEEDED',TRUE] call BIS_fnc_taskSetState",""]; waitUntil { triggerActivated _Trigger1}; sleep 1; [ "task_1" ] call BIS_fnc_deleteTask; }; };  Share this post Link to post Share on other sites