NWN2Wiki
Register
Advertisement

Functions are units of code that perform a specific task. The general format of a function is as follows:

returntype functionname(type parameter1, type parameter2... )
{
   code within the function
}
returntype
The return type defines the type (int, float, etc.) of variable that is returned when the function is executed. All code paths in the function must return this type of variable in order for the script to compile. A function can return any data type, or nothing, which is indicated with the 'void' keyword.
functionname
The function name is used to identify the function. Different functions may share the same name as long as their parameters are not identical. This is called overloading a function.
Parameters
Parameters are variables that are supplied to the function when the function is called. They may be used as defined variables inside the function.
Advertisement