This function can be used to get the name of the function that was used to create a struct when the struct was created using a constructor function and the new operator. You supply the variable with the struct reference to check and the function will return either a string with the function name or undefined. Note that if you pass the function a struct literal (ie: a struct that was created without using a constructor function) then it will simply return the string "struct".
instanceof(struct_id);
| Argument | Description |
|---|---|
| struct | The struct reference to use. |
String or undefined
In this example we must first define the function that will be used as the constructor for the struct:
function init_struct(_a, _b, _c) constructor
{
a = _a;
b = _b;
c = _c;
}
This function can then be used along with the new operator to create a struct and populate it with the variables set to the values of the arguments used in the function:
mystruct = new init_struct(10, 100, "Hello World");
We can then get the name of the function that was used like this:
var _name = instanceof(mystruct);
if is_string(_name)
{
show_debug_message(_name);
}