I think you are cheating a bit there, Wolfrug, since by putting so much on one line, it appears that the script is shorter, when really it is pretty much as long as the SQS version. You also forgot to increment _i and the semi-colon after the final }, but I know they are just things you forgot in a rush ;P You have to remember that good, clear formatting and white space are as important to make code readible and simple as is brevity of lines-of-code:
_i = 0;
while { _i < 10 } do
{
_loon setpos getpos _loon2;
sleep 0.1;
_i = _i + 1;
};
Also, although this is a literal conversion of the original code to SQF, this same thing can be done with:
for "_i" from 1 to 10 do
{
_loon setpos getpos _loon2;
sleep 0.1;
};
This method has two advantages:
* The counter, _i, is automatically created for you and only exists within the for loop (as if you'd used the private command). In this example, _i isn't being used inside the loop either, but that is just more of a reason not to have it exist outside the loop itself, where it could interfere with other "versions" of _i.
* It is easier to avoid counting errors, common with loops, since it is even more obvious that you are counting 1 to 10 inclusive (looping 10 times). Whenever you are messing about using <, <=, > or >= for looping, it is not as clear exactly how many times the loop will be being repeated. I know it is "easy" to get it right, but we shouldn't need to make any effort for something so fundamental to scripting, when there are plenty of "complex" things to be causing us headaches already ;P