Jump to content
Sign in to follow this  
evans d [16aa]

Looping a Script Until a Value is True

Recommended Posts

Ok guys, question time!

I've got a script and it's a great script, really top notch. Problem is, it doesn't do what I want it to do.

_civs = [civ1, civ2, civ3, civ4, civ5];
{_x disableAI "Move"} foreach _civs;
while {!free} do {
   civ1 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";
   civ2 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Ohara";
   civ3 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Cooper";
   civ4 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Rodriguez";
   civ5 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";
   sleep 129};
{_x switchMove "";_x enableAI "Move";} foreach _civs;

This script makes civ1 through 5 sit on the ground in with their hands behind their backs with the variable "free" is false. While "free" is false it will loop around the script every 129 secconds. The problem is, even when the captives are freed ("free" is true) the script still waits 129 secconds until they are "untied."

Someone, please, help me retify this error and make it so that when "free" is true the captives are untied imedietly?

Thanks all,

Bashkire.

Edited by Bashkire
Removed the colouring, added italics and bold.

Share this post


Link to post
Share on other sites

Hi,

I´m no expert but you could use waituntil {free}, so it halts until free is true and then goes on.

Edit: And i just noticed i cannot read the variables in this colour. Colour blindness for the win! :)

Edited by Melmarkian

Share this post


Link to post
Share on other sites

Rightiho! Thanks for that, and yeah, I should've thought about colour blind-ness. And there I was thinking I was being helpful. God I'm an idiot! :j:

Thanks again, I'll let you know how it goes.

Actually, do you think you could post what you mean. I havn't got the foggiest where to add that waitUntil bit in. I would assume at the bit where it says "while {!free} do {"

Edited by Bashkire

Share this post


Link to post
Share on other sites

Hi,

I thought about something like that:

free = false;
_civs = [civ1, civ2, civ3, civ4, civ5];
{_x disableAI "Move"} foreach _civs;

   civ1 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";
   civ2 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Ohara";
   civ3 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Cooper";
   civ4 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Rodriguez";
   civ5 switchMove "ActsPsitMstpSnonWunaDnon_sceneNikitinDisloyalty_Sykes";
   sleep 5;
   waituntil {free};
{_x switchMove "";_x enableAI "Move";} foreach _civs;

No need for a while{] when nothing is done or checked every run. It will just do the switchmoves and then wait until free is true. Then execute the code after the waituntil.

Share this post


Link to post
Share on other sites

Gotcha, trying it now.

Works like a frakking charm! If I ever meet you I owe you a pint!

Thanks again,

Bashkire.

Edited by Bashkire

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  

×