Jump to content
Sign in to follow this  
Rothwell

Making .FSM code wait

Recommended Posts

Does anyone know how to make .fsm code "sleep"? Unfortunately, the sleep command doesn't work with .FSM code for some reason, neither does "waitUntil". I thought this would work:

_i=0;
_timeout = time;

while {(_i<=5)} do {
if(time>(_timeout + 1)) then {
	_flag setPosATL[getPosATL _static select 0, getPosATL _static select 1, (getPosATL _static select 2) - _i];
	_i=_i+.02;
	_timeout = time;
	_flag setFlagTexture "\ca\data\Flag_usa_co.paa";
};
hint"in the loop";
};

unless I'm overlooking a syntax error, it's just not working how it should, it goes into an infinite loop, but never executes what's inside the if statement. Anyone know how to get around this problem?

Share this post


Link to post
Share on other sites

Set a variable...

wait_until = Time + 3.0;

...then add a branch which returns straight back when the condition...

Time > wait_until

...is met. Such questions belong in the scripting sub-forums HERE.

Share this post


Link to post
Share on other sites

You can spawn a new thread in an FSM state.

Share this post


Link to post
Share on other sites

I think Rothwell wanted to use a while-loop with sleep inside a state? But yes, the FSM won't halt at spawn.

Share this post


Link to post
Share on other sites

Ok, well I think Defunkt has come up with the proper way of doing what I want to get done. Thanks.

Share this post


Link to post
Share on other sites

in block

_timeout = [] spawn

{

sleep 10;

};

in condition

scriptdone _timeout

By this way you can loop any code in spawn function and fsm will wait when it done

Edited by Wass
  • Like 1

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  

×