argument

This variable acts as an array that is used along with the read-only variable argument_count in script functions or methods. Each index holds an input value for the function and is specifically for use with variable argument functions (i.e. where the number of arguments can vary between calls).

An argument that hasn't been passed in will be undefined.

Note that there are also a series of independent global scope variables that can also be used in user-defined functions to reference the different input arguments: argument0, argument1, argument2, etc... up to argument15.

NOTE This variable does not hold a real GML array, so you cannot run any array functions on it or serialise it (convert it to a string). The only operation you can run on it is returning a value at an index, with the argument[index] syntax.

 

Syntax:

argument[n]
argument1
argument2
...
argument15

 

Returns:

Any (can be of any data type supplied to the function)

 

Example:

function print()
{
    var _str = "";
    for (var i = 0; i < argument_count; i ++)
    {
        _str += string(argument[i]);
    }
    show_debug_message(_str);
}

// In an object
print("Player : ", current_time, " : ", id, " : fired");

The above function joins all the arguments passed into the function as one string, and then prints that string to the output log.