NPC Code:
if(created || playerenters) {
//intalize vars
this.maxidletime = 30; //time (in seconds) that a player can idle for
}
if(timeout) {
if(this.pos[0] != playerx || this.pos[1] != playery)
this.move=0;
else
this.move+=.05;
this.pos = {playerx,playery};
if(this.move > this.maxidletime) {
//whatever you want to do
}
timeout = 0.05;
}
This would check if you acually MOVED from a spot.