from what I read....
you have a problem of going straight from one number to the other...having an "if (keypressed(#))" wont solve anything, because that would be a one-time action that is sent, like playerchats.
If youve ever done
NPC Code:
if (timeout) {
if (playerchats) {message AHH!;
}
timeout = .1;
}
You'll notice nothing ever happens when you speak...because the chance of the player chatting at the right time (when the timeout loop reaches the IF), are like 1 billion to 1, so if (keypressed(#)) wont work for that reason.
but, to make it so the player doesnt need to have 0.05 second reflexes, you can add a function, like:
NPC Code:
if (timeout) {
if (keydown(5)) { modechange();
}
timeout = 0.5;
}
function modechange() {
this.mode=1-this.mode;
sleep .5;
}
*Note : this can be done without a function, but functions are more organized*
that way the program only waits when a key is pressed...or...you can do this:
NPC Code:
if (timeout) {
if (this.wait>0) this.wait-=1;
if (keydown(5)&&this.wait=0) {this.mode=1-this.mode; this.wait=10;}
timeout = 0.05;
}
that will make it so the NPC will not respond to the s key until .5 seconds have passed since the last press.