PDA

View Full Version : while condition question



JacobJ
Jun 23 2011, 18:55
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

CarlGustaffa
Jun 23 2011, 18:57
why not:
fox = true;
while {fox} do {
...whatever
if (condition) then {fox = false};
};

JacobJ
Jun 23 2011, 19:04
Does the:

if (condition) then {fox = false};

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

MessiahUA
Jun 23 2011, 19:24
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.

JacobJ
Jun 23 2011, 19:31
Okay thanks, I will try that out and see if I can get it working.

ArmASalt3
Jun 23 2011, 21:51
while {true} do
{

if (fox == 1) then
{

code....
};};

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 =)

JacobJ
Jun 23 2011, 21:55
Are okay I see, thats another way to do it. Thank you for that example, I will try that out.