# 3-tick scheduler

global pSch = 0;

global last = false;
global timer = -3;


while(true){

  if((timer == -3) && (pSch > 0)){
    F = true;
    oink();
    timer = 1;
    pSch--;
  }

  if(timer == 0){
    F=false;
  }

  if(timer > -3){
    timer = timer - 1;
  }

  pause();

}


function update(){
  if(B && !last){
    pSch += 3;
  }
  last = B;
}
