It's been like this since A4. If you understand how the code is executed, you'll see why. For example, follow the numbers in "()"s (1,2,3, etc):
Code:
function gimme_a_return() // << (3) this function was called
{
return_value = 2; // << (4) return value is given a value
wait(-1); // << (5) this function is on hold for one frame,
// so control is returned to the calling function
return(return_value); // << (8) We're back after waiting a frame,
// we return a value but, since the calling function
// has already continued without us, we just
// throw away this value.
}
function test_the_return() // << (1) If you call this function first
{
test_return = gimme_a_return(); // << (2) gimme_a_return is called...
// << (6) gimme_a_return was put on hold
// before it got to its return value so
// test_return is assigned the wait value
} // << (7) This fuction is finished
Quote:
So I guess I gotta do the work around, caus I need the wait. (Caus there is a while loop in the function, so there is automaticly a wait(1); )
While loops don't always need waits. It is perfectly legal to do something like this:
Code:
i = 0;
while(i<20)
{
i += 1;
}
Just remember that without the wait, everything happens in one frame so you need to be sure that your loop isn't too big (otherwise things will slow down a lot).