• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

ds_grid_set_region not working properly on web export

B

binaryidiot

Guest
So in my code I have a few calls to ds_grid_set_region, when ran on windows these work exactly as expected, however running on html 5 they will only set a region up to the smaller of the width and the height. The only way I can get my code to work properly is If the ds_grid I'm working with is a square, if it is at all a rectangle then part of it will be all set to 0.

GML:
function createBSPGrid(width, length, minAreaSize, maxAreaSize){   
    //Setup data structures
    var grid = ds_grid_create(width, length);
    
    //Set everything to walls
    ds_grid_set_region(grid, 0, 0, width-1, length-1, wall);
    
    //Assign cords for area
    var x1 = 1, y1 = 1;
    var x2 = width - 2, y2 = length - 2;
    
    //Assign area
    ds_grid_set_region(grid, x1, y1, x2, y2, areaNum);
    
    leaf(grid, x1, y1, x2, y2, minAreaSize, maxAreaSize);
    
    return grid;
}
 

FrostyCat

Redemption Seeker
You can report the bug, but even if it gets addressed, it'll probably be at least a month or so before you can put it through to production.

In the meanwhile, there's always this workaround:
GML:
function ds_grid_set_rectangle(grid, x1, y1, x2, y2, val) {
    for (var i = x1; i <= x2; ++i) {
        for (var j = y1; j <= y2; ++j) {
            grid[# i, j] = val;
        }
    }
}
 
Top