Hi all,
Still working on my trigger switch behavior. I'm really trying to simplify it (to better understand what I'm doing) and also to learn how to debug it.

Right now I can hit enter and the level will move up but when I hit enter again, nothing happens. I have used the watch window and can see that the active_tri variable moves from 0 to 1 but that's where it stops.

Any ideas?

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

ENTITY* t_trigger;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var trig_percentage;
var active_tri = 0;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	while(1)
	{
		if (key_enter)
		{
			if(active_tri == 0)
			{
				while(1)
				{
					trig_percentage += 2*time_step;
					ent_animate(t_trigger, "on", trig_percentage, ANM_SKIP);
					active_tri = 1;
					wait(1);
				}

			}

			if (active_tri == 1)
			{
				while(1)
				{
					trig_percentage += 2*time_step;
					ent_animate(t_trigger, "off", trig_percentage, ANM_SKIP);
					active_tri = 0;
					wait(1);
				}
			}
		}
		wait(1);
	}
}

function main()
{
	level_load ("switch.wmb");
	wait(2);
	vec_set(camera.x, vector(-250, 0, 15));
}