Jump to content
Sign in to follow this  
JacobJ

while condition question

Recommended Posts

Hey all

I have a while (true) loop atm. But how can I use another script to make this loop false, if I don't want it to run anymore?

Can I make a variable like this:

fox = true;

And then put fox into the condition ()'s? And whenever I want to make the loop stop, then just:

fox = false; ?

I have tried, but it doesnt seem to work. Maybe something I have missed about this?

/Jacob

Share this post


Link to post
Share on other sites

Does the:

if (condition) then {fox = false};

have to be inside the while code? Can it not be in another script?

Share this post


Link to post
Share on other sites
Does the:

if (condition) then {fox = false};

have to be inside the while code? Can it not be in another script?

No it hasn't, you can change fox variable anywhere, because it's global.

Share this post


Link to post
Share on other sites

Okay thanks, I will try that out and see if I can get it working.

Share this post


Link to post
Share on other sites

while {true} do
{

[indent]if (fox == 1) then
{
[indent]code....[/indent]


};[/indent]};

put this in a script and run it at init.

Everytime you set fox = 1 (inside ANY SCRIPT in your mission, even in the mission editor... triggers.. etc), it will run the code inside the if statement. If you set fox = 0 it will not run it, until you change it back to 1. Do this as many times as you like =)

Share this post


Link to post
Share on other sites

Are okay I see, thats another way to do it. Thank you for that example, I will try that out.

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  

×