Created
January 29, 2015 10:04
-
-
Save derme302/f6f85b9445b80335f02f to your computer and use it in GitHub Desktop.
Import a array into a ds_grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///ds_grid_import_array(ds_grid, array) | |
var grid = argument[0]; | |
var arr = argument[1]; | |
// Calculate array Size | |
var height = array_height_2d(arr); | |
var width = 0; | |
for (var i = 0; i < height; i++) { | |
if (array_length_2d(arr, i) > width) | |
width = array_length_2d(arr, i); | |
} | |
// Resize ds_grid to the correct dimensions | |
ds_grid_resize(grid, width, height); | |
ds_grid_clear(grid, -1); | |
// Import array into ds_grid | |
for (var i = 0; i < height; i++) { | |
for (var j = 0; j < width; j++) { | |
ds_grid_set(grid, j, i, arr[i, j]); | |
trace("Grid " + string(i) + " , " + string(j) + ":" + string(ds_grid_get(grid, j, i))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example Usage (With CSV Manager Installed):