Skip to content

Instantly share code, notes, and snippets.

@gnysek
Created November 18, 2016 15:58
Show Gist options
  • Save gnysek/969df094eae8e01c7d48dbfc99ccb282 to your computer and use it in GitHub Desktop.
Save gnysek/969df094eae8e01c7d48dbfc99ccb282 to your computer and use it in GitHub Desktop.
ds_map_secure_load_array.gml
var d = ds_map_secure_load(argument0);
var n = ds_map_find_first(d);
while (!is_undefined(n)) {
var is_2d = false;
var size = 0;
if (variable_global_exists(n)) {
if (is_array(variable_global_get(n))) {
size = array_length_2d(variable_global_get(n), 0);
if (size > 1) {
is_2d = true;
}
}
}
if (ds_exists(d[? n], ds_type_list)) {
var i, a = [];
for(i=0; i<ds_list_size(d[? n]); i++) {
if (is_2d) {
a[i div size, i % size] = ds_list_find_value(d[? n], i);
} else {
a[i] = ds_list_find_value(d[? n], i);
}
}
ds_list_destroy(d[? n]);
d[? n] = a;
}
//trace(d[? n]);
n = ds_map_find_next(d, n);
}
return d;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment