NPC Code:
if(playerenters){
timereverywhere;
drawunderplayer;
this.y={5,15}; // {starty,endy}
//getdir to know if it goes first up or down
if(this.y[0] > this.y[1]){this.dir={0,2};}
else {this.dir={2,0};}
this.speed=.5; //speed elevator is moving
this.active=0;
if(isleader){y=this.y[0];}
}
if(playertouchsme){
setani idle,; //Normally u can see the walking gani
this.active=1;
timeout=.05;
}
if(timeout){
if(this.active > 0){
//only if using it
if(this.active==1){
freezeplayer .05;
playerx=x+(width/2-1.5);
playery=y+(height/2-2);
}
moving();
timeout=.05;
}
}
function moving() {
if(this.active==1){
if(abs(this.y[1]-y) > 0){y+=vecy(this.dir[0])*this.speed;}
else {this.active=2;}
}
if(this.active==2){
if(abs(this.y[0]-y) > 0){y+=vecy(this.dir[1])*this.speed;}
else {this.active=0;}
}
}
should be easy to edit it ^_^