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);
}
}