Page 1 of 1

Door script

Posted: January 30th, 2013, 3:53 pm
by xxG
Please help me with the script

Code: Select all

main()
{
 doortriggers = getentarray( "doortrig", "targetname" );
 for(i=0;i<doortriggers.size;i++)
 doortriggers[i] thread door_think();
}
 
door_think()
{
 self.doormoving = false;
 self.doorclosed = true;
 self.doormodel = getent(self.target, "targetname");
 
 while (1)
 {
 self waittill("trigger");
 if(!self.doormoving)
 self thread door_move();
 }
}
 
door_move()
{
 self.doormoving = true;
 if(self.doorclosed)
 {
 self.doormodel rotateyaw(-90,1,0.5,0.5);
 self.doormodel waittill("rotatedone");
 self.doorclosed = false;
 }
 else
 {
 self.doormodel rotateyaw(90,1,0.5,0.5);
 self.doormodel waittill("rotatedone");
 self.doorclosed = true;
 }
 self.doormoving = false;
}
I want to trigger the use of the door was opened and waited for 5 seconds then closes.

Re: Door script

Posted: January 30th, 2013, 9:21 pm
by Drofder2004
The script you are using is a door toggle.

Code: Select all

main()
{
   doortriggers = getentarray( "doortrig", "targetname" );
   for(i=0;i<doortriggers.size;i++)
      doortriggers[i] thread door_think();
}
 
door_think()
{
   self.doormodel = getent(self.target, "targetname");
 
   while (1)
   {
      self waittill("trigger");
      self door_move(); /* Removing 'thread' will pause the script until door is closed */
   }
}
 
door_move()
{
   /* Open Door */
   self.doormodel rotateyaw(-90,1,0.5,0.5);
   self.doormodel waittill("rotatedone");
 
   wait 5; /* 5 Second Wait */
 
   /* Door Close */
   self.doormodel rotateyaw(90,1,0.5,0.5);
   self.doormodel waittill("rotatedone");
}
Just in case you have no idea what the script does and requires. You must create a trigger with key/value of "targetname/doortrig", then create a door (script_brushmodel) and finally connect the two (click trigger, then click door, press 'W').

Re: Door script

Posted: January 31st, 2013, 6:37 pm
by xxG
Thanks it works