The "ds_struct_set" Function


ds_struct_set(id, key, value);
idstructThe struct to modify
keystringThe key to assign a value to
valueanyThe value (number, string, array, struct, data structure, etc.) to assign


Assigns a value to the specified key within the given struct. The struct must have been previously created (e.g. with ds_struct_create).

If multiple levels of struct exist, it is possible for the same key to occur multiple times with different values. To increase the speed and precision of this function, you can specify which level to search by prepending the key with any parent structs separated by a period. In this case, the first parent specified must exist in the root struct, but deeper levels will be recursed and are optional, provided the key already exists. If the key does not exist, any parents will be created as well in the order specified.

To get the value of a key once set, use ds_struct_find_value.


// Both "font" and "text.font" are acceptable and will assign the same value
ds_struct_set(my_struct, "text.font", fnt_Arial);