For checking if you're on the grid, you can either use place_snapped(16,16) or you can check something like if (x mod 16 == 0 && y mod 16 == 0). The latter says that you are on an x and y position that is a multiple of 16 or where x == 0 or y == 0, which if you think about it is every grid-space.
I had noticed you looked at my Pokemon example earlier; which could still be improved considering all I have learned now about stuff - namely creating an objWall object which would represent things you could run into rather than initially doing a place_free check (assuming my code had that in it).
In the Pokemon movement at least, if you pressed both left/right or up/down, the character would move because one of those directions would just take primacy. The Gameboy control pad pretty much makes it so one can't press down keys like that though. Your key pressing for movement can thus be simplified to if, else if, and then an else statement for when no keys are pressed. Also don't know why you're doing sprite changing in the Begin Step: it won't reflect accurately what sprite you are when you move. Also about having a facing variable, use the built-in variable direction; it's more efficient.
The xprevious < x and similar checks for direction aren't really needed either if you set the direction correctly as the direction can only be set when you are on a grid-space, you shouldn't be able to change it when between them. Additionally that part about where you check if you're pressing up and left and then correcting the direction would also be unneeded if you coded the key movement correctly as I mentioned above.
I'd recommend looking at my Pokemon walking stuff again. If you want it to be more general but don't know how to make it so I could help you out with that too.