////////A5 Script for doors with trigger//////////
///////You could use this script for one door by “//” one of them/////
entity* 2my_gate1;
entity* 2my_gate2;
function mygate_open() // Desc: open gate
{
if(MY.SKILL1 > 0){END;}
MY.SKILL1 = 5;//////////how fast the door opens
WHILE (MY.SKILL2 < 85)//how far the door swings open
{
MY.SKILL2 +=MY.SKILL1*TIME;
if(MY.FLAG1 == ON){MY.PAN += MY.SKILL1*TIME;}
if(MY.FLAG2 == ON){MY.PAN -= MY.SKILL1*TIME;}
WAIT 1;
}
MY.SKILL2 = 85;
MY.SKILL1 = 0;
}
function mygate_close() // Desc: close gate
{
if(MY.SKILL1 > 0){END;}
MY.SKILL1 = 5;///////// how fast the door opens
WHILE (MY.SKILL2 > 0)
{
MY.SKILL2 -=MY.SKILL1*TIME;
if(MY.FLAG1 == ON){MY.PAN -= MY.SKILL1*TIME;}
if(MY.FLAG2 == ON){MY.PAN += MY.SKILL1*TIME;}
WAIT 1;
}
if(MY.FLAG1 == ON){MY.PAN =270;}//door on left side
if(MY.FLAG2 == ON){MY.PAN =90;}//door on right side
MY.SKILL2 = 0;
MY.SKILL1 = 0;
}
/*
After placing the doors in your level, click on it, and in its properties
set one "Flag1" and the other "Flag2, then look at what the pan angle is
and enter that number in the MY.PAN = ;//door left do the same for other.
You may have to rotate a door 180 degs on the pan angle depending on which side the door is hinged.
*/
function 2mygate_start()
{
{
ME = 2my_gate1;
mygate_open();
wait(1);
ME = 2my_gate2;
mygate_open();
}
}
function 2mygate_stop()
{
{
ME = 2my_gate1;
mygate_close();
wait(1);
ME = 2my_gate2;
mygate_close();
}
}
ACTION 2mygate_gate1 //info from "template/doors.wld -> gate"
{
MY.EVENT = NULL;
MY.ENABLE_SCAN = OFF;
MY.ENABLE_CLICK = OFF;
2my_gate1 = ME;
}
ACTION 2mygate_gate2 //info from "template/doors.wld -> gate"
{
MY.EVENT = NULL;
MY.ENABLE_SCAN = OFF;
MY.ENABLE_CLICK = OFF;
2my_gate2 = ME;
}
/////////////////////////////////////////////////////////////////
// Desc: attach to trigger to open door "2mygate start"
///////////////////////////
ACTION 2my_onTrigger
{
MY.EVENT = 2mygate_start;
MY.ENABLE_SONAR = ON;
}
// Desc: attach to trigger to close door "2mygate stop"
/////////////
ACTION 2my_offTrigger
{
MY.EVENT = 2mygate_stop;
MY.ENABLE_SONAR = ON;
}
}