Did you try adding "my.STATE = 1;" in the part of the jumping?
Code:
if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
		{
							//jump
			movedir.z = -jumpacc;
			my.STATE = 1;
		}


If that doesn't do the trick, try to rebuild the code from scratch, thinking about what is the beginning and what is to be add next, adding one thing at a time, testing, add another, testing, and so on.