So right now, I hit enter and the switch moves to the down position. When I hit enter again, nothing happens. hit it again, and it moves up. After that, it stops working all together.

I'm curious about the trig_percentage check in the while statement. Why is that used?

Code:
action trigger_switch()
{
	t_trigger = me; //this is a pointer defining the entity listed at the top
	var active_tri = 0;

	while(1)
	{
		if (key_enter)
		{
			if(active_tri == 0)  //this is the initial state of the trigger (middle)
			{
				active_tri = 1;  //position for up
			}
			if(active_tri == 1)
			{
				active_tri = 2;  //postion for down
			}
			if(active_tri == 2)
			{
				active_tri = 1;
			}
		}
		if(active_tri == 1)
		{
			while(trig_percentage > 0)
			{
				//			trig_percentage %= 100;
				trig_percentage += 2*time_step;
				ent_animate(t_trigger, "on", trig_percentage, ANM_SKIP);
				wait(1);
				//			trig_percentage = 0;
			}
			while(trig_percentage < 100)
			{
				//			trig_percentage %= 100;
				trig_percentage += 2*time_step;
				ent_animate(t_trigger, "off", trig_percentage, ANM_SKIP);
				wait(1);
				//			trig_percentage = 1;
			}
			active_tri = 2;
		}
		if (active_tri == 2)
		{
			while(trig_percentage > 0)
			{
				//			trig_percentage %= 100;
				trig_percentage += 2*time_step;
				ent_animate(t_trigger, "on", trig_percentage, ANM_SKIP);
				wait(1);
				//			trig_percentage = 0;
			}
			while(trig_percentage < 100)
			{
				//			trig_percentage %= 100;
				trig_percentage += 2*time_step;
				ent_animate(t_trigger, "off", trig_percentage, ANM_SKIP);
				wait(1);
				//			trig_percentage = 1;
			}
			active_tri = 1;
		}
		wait(1);
	}

}