You could change your movement things so they look like this:
NPC Code:
if (keydown(1)&&!onwall(playerx,playery+1.5) {
playerx-=0.5;
playerdir = 1;
}
the playerx, and playery+1.5 are the co-ordinates where it looks to see if its onwall, do same for other directions, changing the co-ordinates of the onwall for each... or you can add something like this:
NPC Code:
if (keydown(1)&&onwall(playerx,playery+1.5) {
playerx+=0.3;
playerdir = 1;
}
this'll just bounce him back if in the wall, but youll have to have the original movement script as well.