2023-02-14 02:48:33 +01:00
|
|
|
#macro struct_has variable_struct_exists
|
|
|
|
|
|
|
|
function struct_override(original, override) {
|
|
|
|
var args = variable_struct_get_names(override);
|
|
|
|
|
2023-07-25 20:12:40 +02:00
|
|
|
for( var i = 0, n = array_length(args); i < n; i++ ) {
|
2023-02-14 02:48:33 +01:00
|
|
|
if(!struct_has(original, args[i])) continue;
|
|
|
|
original[$ args[i]] = override[$ args[i]];
|
|
|
|
}
|
|
|
|
|
|
|
|
return original;
|
2023-05-28 20:57:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function struct_try_get(struct, key, def = 0) {
|
2023-06-13 14:42:06 +02:00
|
|
|
if(struct_has(struct, key)) return struct[$ key];
|
|
|
|
key = string_replace_all(key, "_", " ");
|
2023-05-28 20:57:54 +02:00
|
|
|
return struct_has(struct, key)? struct[$ key] : def;
|
2023-02-14 02:48:33 +01:00
|
|
|
}
|