• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [Solved]Tilemap_set() errors

So I had this working perfectly a few days ago but after I split this into a separate script it totally screwed it up. Basically I have it set so when I press space it generates a whole new level. Previously it would generate an entire new level and tile it just fine. Now it spawns the enemies but doesn't tile when I restart the room. I get an error in the output window that says
tilemap_set() - couldn't find specified tilemap
I am so confused. I have tried basically everything I can think of. I put it back into the original body and it still causes the same issue. I have tried changing the enemy to a blank object with no code. Changed it to game restart rather than room. Rewrote the code in another script. Nothing is working and its driving me nuts.

Code:
for(yy = 0; yy<height; yy++){
    for(var xx = 0; xx < width; xx++){
        if(grid[# xx, yy] == FLOOR){
            tilemap_set(backgroundLayer,2,xx,yy);

            var odds = 5;
            var ex = xx*cellWidth+cellWidth/2
            var ey = yy*cellHeight+cellHeight/2
            var filled = false;
            odds = 5;
            if(!filled && irandom(odds) == odds){
                instance_create_depth(ex,ey,1,obj_enemy)
                filled = true;
            }
                
        }else if(grid[# xx,yy] == WALL){
            tilemap_set(backgroundLayer,1,xx,yy);
            mp_grid_add_cell(gridPath,xx,yy)
        }
    }
 
I figured it out. I honestly have no idea why it was working at all. It would work 100% without the spawn code but the spawn code isn't directly related. I just changed a couple of vars that I was passing in and now it works. Weirdest problem I have ever had.
 
Top