ENTITY* t_switch;
ENTITY* t_trigger[100]; // set a hard max and do not exceed
var trig_percentage;
var t_switch_range = 150;
var trigger_ids=0;
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.
t_trigger[trigger_ids] = me; // index from 0-499
trigger_ids+=1;
my.skill10 = 0; /// active_tri must be moved to a skill not a var
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(my.skill10 == 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);
}
my.skill10 = 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);
}
my.skill10 = 0;
}
}
}
}
wait(1);
}
}
action door_or_platform()
{
wait(3); /// or other wait to make sure level is loaded
var door_ids;
door_ids += 1;
my.skill80 = door_ids // 1-500 this id matches t_trigger +1. so t_trigger[2] == my.skill80=3;
my.skill10 = 0;
while(1)
{
my.skill10 = t_trigger[my.skill80-1].active_tri;
if(my.skill10 == 0)
{
my.x += 25
}
if(my.skill10 == 1)
{
my.x -= 25
}
wait(1);
}
}