My animation script in pseudo-code... a little help?

Here’s the situation… I have created a character in Blender, and she has 6 animations: Stand, Walk, Run, Jump, Land (from a jump), and Bored.

Now, I’ve been playing around with the Javascript code for making the character move when she’s supposed to, and it looks half-decent, but it’s definitely buggy. The problem is that I can’t figure out the proper times to use CrossFade, CrossFadeQueued, Blend, PlayQueued… it’s getting beyond me.

So, I’ve written out what I think I want the character to do in fake “pseudo-code”. Anyone have advice?

if (character is standing still) {
 if (character has not jumped or walked anywhere for 7 seconds) {
  fade 0.3 secs into the BORED animation;
 }
} else {
 if (character is jumping) {
  fade 0.3 secs into the JUMPING animation;
 }
 if (character is on the ground) {
  if (character was in the air and has contacted the ground this frame) {
   if (character is moving at running speed) {
    fade 0.3 secs into the RUNNING animation;
   } else if (character is moving at walking speed) {
    immediately play the LANDING animation, but fade 0.3 secs into the WALKING animation;
   } else {
    immediately play the LANDING animation;
    when landing animation is finished, play the STANDING animation;
   }
  } else {
   if (character is moving at running speed) {
    fade 0.3 secs into the RUNNING animation;
   } else if (character is moving at walking speed) {
    fade 0.3 secs into the WALKING animation;
   }
  }
 }
}

I think it must be something like that:

var lastMove = 0.0;
var runSpeed = 5.0;
var walkSpeed = 2.0;
private var temp = 0.0;
private var t : boolean = false;
priavte var grounded : boolean = false;
var speed = CharacterController.relativeVelocity.magnitude

function OnCollisionStay () {
 grounded = true;
}

function Update () {
if (Input.GetAxis("Horizontal") == 0.0  Input.GetAxis("Vertical") == 0.0  Input.GetButton("Jump") == false) { 
 if (lastMove <= Time.time - 7.0) { 
  animation.CrossFade("Bored", 0.3); 
 } 
} 
else { 
 if (Input.getButton("Jump")) { 
  animation.CrossFade("Jump", 0.3); 
 } 
 if (grounded == true) { 
  if (...?...) { 
   if (speed >= runSpeed) { 
    animation.CrossFade("Run", 0.3); 
   } else if (speed >= walkSpeed  speed < runSpeed) {
    if (Time.time < temp + 0.3) {
      animation.CrossFade("Landing", 0.2);
      if (t == false) {
       temp = Time.time;
       t = true;
    }
    else {
      animation.CrossFade("Walk", 0.2);
      t = false;
    }
   } 
   else { 
    animation.CrossFade("Landing", 0.1);
    animation.PlayQueued("Standing", QueueMode.CompleteOthers);
   } 
  } else { 
   if (speed >= runSpeed) { 
    animation.CrossFade("Run", 0.3); 
   } else if (speed >= walkSpeed  speed < runSpeed) { 
    animation.Crossfade("Walk", 0.3); 
   } 
  } 
 } 
}