struct_set

With this function you can set the value of a given variable in a struct. You supply the struct reference as well as the name of the variable to set the value of as a string (see example code below), and then finally the value to set (can be any valid data type). If the variable does not exist already in the struct it will be created and then assigned the value.

 

Syntax:

struct_set(struct, name, val);

ArgumentTypeDescription
structStructThe struct reference to set
nameStringThe name of the variable to set (as a string)
valAnyThe value to set the variable to

 

Returns:

N/A

 

Example:

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

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