P. 1


|Views: 450|Likes:
Published by Robert Cox

More info:

Published by: Robert Cox on Apr 15, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





While script syntax (see exec) is line based, functions (see call, then, do) is based on structured
expressions and end-of-line has no special meaning, it is considered to be equivalent to a space.
Semicolon is therefore required even when ending a line. Note: scripts can do some things that are not
possible in functions. Scripts can wait suspended until a certain condition it met and they can also use
goto to change the execution point at any time.

Main language contructs used in functions are:
Curled braces
Multiple commands (including assigment commands) delimited with a semicolon

The result of the last expression evaluated is returned as a function result. This can be nothing
when a function returns no value.

Example 1 (max.sqf)

comment "Return the maximum of the first and second argument";
private {"_a","_b"};
_a = _this select 0;
_b = _this select 1;
if (_a>_b) then {_a} else {_b}

Example 2 (infantrySafe.sqf)

comment "Switch all infantry units to safe mode";

if (vehicle _x == _x) then

_x setBehaviour "safe"

} forEach _this

Page 407of 415

BIS Game Engine Scripting Commands



Due to the line-based nature of scripts it is not possible to create multiline string constants in them.
To overcome this limitation you can store multiline in separate files and load them using the loadFile
or preprocessFile functions (the second uses a C-like preprocessor with // or /* */ comments and
#define macros). The recommended file extension for functions is .SQF (as opposed to .SQS used for

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->