It's actually a very small change to the script I made which made it walk in 4 ways

:
NPC Code:
for (i=0; i<4; i++) if (this.key[i]==true) {
playermoved = true;
this.dir = i;
newx = this.x + this.dirgo[i*2]*this.speed;
newy = this.y + this.dirgo[i*2+1]*this.speed;
// Check for walls
setarray wall,6;
for (j=0; j<6; j++)
wall[j] = onwall(newx+this.Cwalltest[i*12+j*2],
newy+this.Cwalltest[i*12+j*2+1]);
// Test for walls in front;
if (wall[0]==true || wall[1]==true || wall[2]==true || wall[3]==true) {
// Move the player outside of the wall
if (i==0) this.y = int(this.y);
else if (i==1) this.x = int(this.x+0.5)-0.5;
else if (i==2) {
if (this.y!=int(this.y)) this.y = int(this.y+1);
} else if (i==3) {
if (this.x+0.5!=int(this.x+0.5)) this.x = int(this.x+1.5)-0.5;
}
} else {
// Apply new position
this.x = newx;
this.y = newy;
}
// Test 'sidemoves'
if (wall[0]==true && wall[2]==false && wall[3]==false && wall[4]==false) {
this.x += this.sidemove[i*4];
this.y += this.sidemove[i*4+1];
} else if (wall[0]==false && wall[1]==false && wall[3]==true && wall[5]==false) {
this.x += this.sidemove[i*4+2];
this.y += this.sidemove[i*4+3];
}
i=4;
}
Note that I added an i=4 to the end of the thing to prevent diagonal movement.