Page 1 of 1

2 trigger = 1 door

Posted: July 10th, 2010, 10:07 am
by Levcek
ok i need a little help... i dont know how to make that two triggers will open one door so heres the question:

do anyone know how to make that 2 triggers will open 1 door

plz help ^^

tnx

Re: 2 trigger = 1 door

Posted: July 10th, 2010, 10:52 am
by Rezil
Same scripting as with one door, only give the two triggers the same targetname.

Re: 2 trigger = 1 door

Posted: July 10th, 2010, 11:34 am
by JuMPZoR
You think you can post the regular script to open 1 door, Rez?

Re: 2 trigger = 1 door

Posted: July 10th, 2010, 11:59 am
by Rezil

Code: Select all

//Simple door opening script by Rezil
main()
{
	thread mp_jm_mapname_door(); //Change to avoid conflicts with other .gscs
}

mp_jm_mapname_door()
{
	t = getent("trig","targetname"); //trig is the targetname of the trigger you will use to open the door
	d = getent("door","targetname"); //door is the targetname of the actual door that will open and "d" is what we will call it in the script
	
	while(1)
	{
		t waittill("trigger", user); //wait for the user to trigger
		d rotateyaw(90,1,0.5,0.2); //this rotates the entity(in our case, "door") 90 degrees in 1 second with the entity accelerating 0.5 seconds and deccelrating for 0.2 seconds
		d waittill("rotatedone"); //wait for the door to stop rotating, better than simply using the wait command as it prevents bugging the door(blocking it)
		t delete(); //door is open, delete trigger
	}
}
That's the basic code, you can of course check whether the door is open or not and what the code will do accordingly. Like this:

Code: Select all

//A bit more advanced door opening script by Rezil
main()
{
	level.is_door_open = false; //Define a global boolean(true/false) variable that will be used for checking whether the door is open or not
	thread mp_jm_mapname_door(); //Change to avoid conflicts with other .gscs
}

mp_jm_mapname_door()
{
	t = getent("trig","targetname"); //trig is the targetname of the trigger you will use to open the door
	d = getent("door","targetname"); //door is the targetname of the actual door that will open and "d" is what we will call it in the script
	
	while(1) //while true, infinite loop basically
	{
		t waittill("trigger", user); //wait for the user to trigger
		if(level.is_door_open) //if the global variable is_door_open is true
		{
		d rotateyaw(90,1,0.5,0.2); 
		d waittill("rotatedone");
		//user iprintln("Door open."); //Optionally inform the user that the door is open 
		}
		else { //do this if all other checks are false - you could do the same with if(!level.is_door_open)
		d rotateyaw(-90,1,0.5,0.2); //-90, close the door
		d waittill("rotatedone"); 
		//user iprintln("Door closed."); //Optionally inform the user that the door is closed
		}
	}
}
Untested but should work.

Re: 2 trigger = 1 door

Posted: July 11th, 2010, 1:01 pm
by JuMPZoR
Thanks, will try it today.