struct_exists

This function checks whether a variable exists within the given struct or not. You supply the struct reference to use as well as the variable name to check for as a string (see example code below). The function will return true if a variable with the given name exists for the struct and false otherwise.

 

Syntax:

struct_exists(struct, name);

ArgumentTypeDescription
structStructThe struct reference to check
nameStringThe name of the struct variable to check for (as a string)

 

Returns:

Boolean

 

Example:

if !struct_exists(mystruct, "shields")
{
    mystruct.shields = 0;
}

The above code will check to see if the variable called "shields" exists in the given struct and if it does not then it is created and initialised to 0.