Jump to content
Sign in to follow this  
blaunarwal

Problem with while loop and function value return

Recommended Posts

Can someone please help me with that? The first script is intended to unload a vehicle from an aircraft. The called function inside is to check, if the aircraft has stopped before the car will be unloaded.

The while loop doesn't run, the stpd.sqf function is not called this way. Whats wrong? :confused:

// usage nul = [car,aircraft] execVM "dismount.sqf"

_lcar = _this select 0;
_lac  = _this select 1;
_lacDir = getdir _lac;
_run = true;
stopp=false;


_lac setfuel 0;
_lac animate ["ramp_top",1];
_lac animate ["ramp_bottom",1];
[color="Red"]while _run DO {
nil = [_lac] execVM "stpd.sqf"
_run=!stopp
};[/color]

hint "Jump Out";
detach _lcar;
_lcar setPos [(getPos _lac select 0) - (15 * sin _lacDir), (getPos _lac select 1) - (15 * cos _lacDir), 0];
sleep 5;
_lac animate ["ramp_top",0];
_lac animate ["ramp_bottom",0];
_lac setfuel 1;
_lac dofollow _lac;
exit;

// usage nil = [hercules] execVM "stpd.sqf"

//titletext ["Stopped function running","PLAIN DOWN"];
_veh = _this select 0;
_stpbol = false;

_pos1 = getpos _veh;
sleep 1;
_pos2 = getpos _veh;


_dx = abs ((_pos1 select 0) - (_pos2 select 0));
_dy = abs ((_pos1 select 1) - (_pos2 select 1));

// for debug reasons only
titletext [format ["Stopped function %1, x = %2, y = %3",_stpbol, _dx,_dy],"PLAIN DOWN"]; 
// for debug reasons only

stopp = (_dx + _dy < 1)
// [color="red"]how can I return the result value to the function? I use a global variable, is this the way? [/color]

exit;

Thank you fore taking your time. :)

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  

×