I've now got my trigger system so it detects the player and will only active if the player is near and hits enter. What I want to do now is so when the switch is triggered in one direction, a platform or door moves one way and when the switch is hit again, it moves another way. Therefore I'm going to need a new action that is applied to the door/platform and a way of identifying which switch triggers what door/platform. That's likely going to be a skill defined when adding the door/platform behavior. Any ideas on where to start?

Here's my code so far:

Code:
ENTITY* t_switch;

var trig_percentage;
var t_switch_range = 150;

action trigger_switch()
{
	while (!player) {wait (1);} // wait until the player is loaded
	vec_set (my.skill61, my.x); // store the xyz initial position of the switch inside skill61... 63
	t_trigger = me; //this is a pointer defining the entity listed at the top
	var active_tri = 0; //variable defining where the switch is currently at.

	while(1)
	{
		c_scan(my.x, my.pan, vector(360, 180, t_switch_range), IGNORE_ME | SCAN_ENTS); // each switch scans around it, trying to detect the player
		if (you) // detected an entity?
		{
			if (you == player) // and that entity is the player?
			{
				if (key_enter)
				{
					if(active_tri == 0)
					{
						trig_percentage =0;
						while(trig_percentage < 100)  //stops an infinite loop. 
						{
							trig_percentage += 2*time_step;
							ent_animate(t_switch, "on", trig_percentage, ANM_SKIP);
							wait(1);
						}
						active_tri = 1;

					}

					else
					{
						trig_percentage = 0;
						while(trig_percentage < 100)  //stops an infinite loop. 
						{
							trig_percentage += 2*time_step;
							ent_animate(t_switch, "off", trig_percentage, ANM_SKIP);
							wait(1);
						}
						active_tri = 0;
					}
				}
			}
		}
		wait(1);
	}
}