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.
struct_set(struct, name, val);
Argument | Type | Description |
---|---|---|
struct | Struct | The struct reference to set |
name | String | The name of the variable to set (as a string) |
val | Any | The value to set the variable to |
N/A
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.