Results 1 to 3 of 3

Thread: Making a working door

  1. #1
    ... connecting
    Join Date
    Nov 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making a working door

    hi im trying to make a door that opens when you use a trigger_use

    it works just fine but the button only opens it once?

    i want the door to open and close after 4 secs

    then after 10 seconds you can push button again to open door again

    can someone help? thanks

    Code:
    button = getEnt("button", "targetname");
    	door = getEnt("door", "targetname");
        button waittill("trigger", player);
    	
        angle = 90; // 4 times = one full round
        seconds = 1;
            
        {	
            for (i=0; i<1; i++)
            {            
                door rotateYaw(angle, seconds);
    			door waittill("rotatedone");
    			wait 4;
    			angle = -90;
    			seconds = 1;
    			door rotateYaw(angle, seconds);
    			door waittill("rotatedone");
    			wait 0.5;
            }
            }

  2. #2
    Private
    Join Date
    Jul 2012
    Posts
    76
    Thanks
    9
    Thanked 56 Times in 38 Posts
    You'll need a while(true) loop to make it work.
    Also: If you use getEnt() you won't need a for( ; ; ) loop, since there's only one entity.
    Like this:

    Code:
    Function()
    {
    	button = getEnt("button", "targetname");
    	door = getEnt("door", "targetname");
    	
    	angle = 90; // 4 times = one full round
    	seconds = 1;
    	
    	while(true)
    	{
    		button waittill("trigger");
    		door rotateYaw(angle, seconds);
    		door waittill("rotatedone");
    		wait 4;
    		door rotateYaw(angle*-1, seconds);
    		door waittill("rotatedone");
    		wait 10; //wait 10 seconds before next use
    	}
    }
    Some more pieces of information:

    Code:
    button waittill("trigger", player);
    If the player is not needed in the script, so if you do not care who the player is who opened the door you can simply leave the player variable. Like this:

    Code:
    button waittill("trigger");
    I did not test the function so please be aware of that. But it does look kinda correct to me.
    Good luck with what ever you're doing
    Last edited by Peterlankton; 28th November 2012 at 15:14.

  3. The Following User Says Thank You to Peterlankton For This Useful Post:

    kung foo man (29th November 2012)

  4. #3
    ... connecting
    Join Date
    Nov 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks it works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •