is_callable

This function returns whether the given argument is callable, i.e. is a method or refers to an index of a function.

A function index can refer to either a built-in function, a Script Function or a Script Asset.

NOTE To only check if a value is a method, see is_method.

Syntax:

is_callable(n);

ArgumentTypeDescription
nAnyThe value to check

 

Returns:

Boolean

 

Example:

function my_function()
{
    return random(10);
}
my_method = function()
{
    return "Hello World!";
}

show_debug_message(is_callable(my_function));
show_debug_message(is_callable(my_method));
show_debug_message(is_callable(draw_text));

The above code first defines a function my_function and a method my_method. It then shows three debug messages. Each shows the result of calling is_callable: the first on my_function, the second on my_method and the third on the built-in draw_text. All three debug messages will show 1, as all three are callable.