Jump to content
Sign in to follow this  
chaoticgood

Two while loops at the same time.

Recommended Posts

while{true}do
{
stuff1
};
while{true}do
{
stuff2
};

In the example code I have given, only stuff1 is done. Is there a way to run stuff1 and stuff2 simultaneously?

Share this post


Link to post
Share on other sites

while{true}do
{
	stuff1;
	stuff2;
};

Though I guess if you didn't try that, there must be a reason. You should explain your problem a little more, maybe?

Something like that could be used, but it'll create two new threads:

[] spawn {
while{true}do
   {
	stuff1;
   };
};

[] spawn {
while{true}do
   {
	stuff2;
   };
};

Share this post


Link to post
Share on other sites

Run it as another script, add the stuff2 to the stuff1 code block, spawn the stuff2 while, not have that many while true stuff.

Share this post


Link to post
Share on other sites
while{true}do
{
	stuff1;
	stuff2;
};

Though I guess if you didn't try that, there must be a reason. You should explain your problem a little more, maybe?

Just a wild guess here, but stuff1 and stuff2 probably take time, so they have to wait for eachother to finish, before continuing. So, they need to happen simultaniously.

Share this post


Link to post
Share on other sites

If something takes time and requires something else that takes time to finish before it can go on, it needs to be redesigned. :)

Share this post


Link to post
Share on other sites
[] spawn {
while{true}do
   {
	stuff1;
   };
};

[] spawn {
while{true}do
   {
	stuff2;
   };
};

Thanks, that does exactly what I need.

Share this post


Link to post
Share on other sites

I helped out on one of the Domination-esque missions

A Paradrop was required.

the AO was checked for completion in a While loop. - While {CurrentAO}

I created another inside of that waiting for the radio tower to come down. While {alive radiotower}

It called the drop when the troops at AO dropped below a certain %

instead of while {true} I would use a variable that was either changed in the mission (alive obj) or by scripts inside the internal loop.

while {_varBoolean} do {

stuff1;

stuff2;

if (something == 0) then {_varBoolean=false}; //0 is a place holder for any value

};

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  

×