Functions
From ZDoom Wiki
Functions are - like scripts - an arbitrary number of sequenced commands. Unlike scripts, functions are identified by a name and can be easily called from anywhere in your scripts or other functions. They can also return a value to the calling script or function. You can place functions anywhere in your script file.
Note: you can not use latent functions (Delay) in your functions.
Functions have to be defined like this:
function type function_name([type arg1 [, type arg2 [...]]])
{
// function body
return value;
}
- type - variable type the function will return. Use void to not return anything
- function_name - the name of the function. It is used to execute the function. Note that function names may not contain blanks
- type argx - type is the variable type of the argument. argx is the name of the variable as which it is used in the function
- return - optional. The function will return this value
Example:
#include "zcommon.acs"
script 1 open
{
int ret;
ret = square(3);
print(s:"the square of 3 is ", d:ret);
}
function int square(int val)
{
return val * val;
}

