Script help

Have questions about CoD4 mapping that aren't covered in the tutorials section? Post here!

Moderator: Core Staff

Post Reply
Sheep_Wizard
CJ Wannabe
CJ Wannabe
Posts: 9
Joined: August 5th, 2013, 6:35 pm

Script help

Post by Sheep_Wizard » August 31st, 2013, 5:33 pm

i'm making a deathrun map and when i something to be triggered i want the multiple brushes to move back and forth but then i activate it it does the first move and then just stops. Can anyone tell me what i'm doing wrong.
I'm using this code:

Code: Select all

trap5()
{
     trig = getEnt("trap5_trig","targetname");
	 pole = getEnt("trap5_pole", "targetname");
	 pole2 = getEnt("trap5_pole2", "targetname");

	 
	 trig waittill ("trigger", player);
	 trig delete();
	 
     while(1)
	{
	 pole movey( -100, 2 );
	 pole2 movey( 200, 2 );
	 pole waittill ("movedone");
	 pole2 waittill ("movedone");
	 pole movey( 100, 2 );
	 pole2 movey( -200, 2 );
	 pole waittill ("movedone");
	 pole2 waittill ("movedone");
	}
}

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Script help

Post by Drofder2004 » August 31st, 2013, 9:29 pm

Code: Select all

   pole movey( -100, 2 );
    pole2 movey( 200, 2 );
    pole waittill ("movedone");
    pole2 waittill ("movedone");
Remember, code is executed in the order you place it.

Code: Select all

Pole 1 starts moving,
Pole 2 starts moving (at the same time)
Pole 1 is waiting for a movement to end... (script pauses)
Pole 1 finishes moving
Pole 2 finishes moving
Pole 1 stops waiting (script resumes)
Pole 2 is waiting for a movement to end... (script pauses)
... script is now stuck waiting for an entity to move.
For basic movement stuff, either use a single waittill, or use a timed wait.
If you want to get fancy you can try:

Code: Select all

// Place at top of script
#include common_scripts\utility;
// ---
 
level waittill_multiple_ents(pole, "movedone", pole2, "movedone");
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Sheep_Wizard
CJ Wannabe
CJ Wannabe
Posts: 9
Joined: August 5th, 2013, 6:35 pm

Re: Script help

Post by Sheep_Wizard » September 1st, 2013, 11:34 am

Drofder2004 wrote:

Code: Select all

 
 
For basic movement stuff, either use a single waittill, or use a timed wait.
 
So how would i fix this so they move back forth using a timed wait or a single waittill, I'm new to this so still learning :)

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Script help

Post by Drofder2004 » September 1st, 2013, 5:30 pm

Sheep_Wizard wrote:
Drofder2004 wrote:

Code: Select all

 
 
For basic movement stuff, either use a single waittill, or use a timed wait.
 
So how would i fix this so they move back forth using a timed wait or a single waittill, I'm new to this so still learning :)
You assign a time period in the function
e.g MoveX( <distance>, <time>);

If you know how long it takes for an action to take, you can wait that amount of time.
This is a looping back and forward movement.

Code: Select all

while(1)
{
   ent_a moveX(100, 2);
   ent_b moveX(100, 2);
   wait 2;
   ent_b moveX(-100, 2);
   ent_a moveX(-100, 2);
   wait 2;
}
If you want to use "waittill" you can, but only wait for a single entity.

Code: Select all

while(1)
{
   ent_a moveX(100, 2);
   ent_b moveX(100, 2);
   ent_b waittill("movedone");
   ent_b moveX(-100, 2);
   ent_a moveX(-100, 2);
   ent_a waittill("movedone");
}
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Sheep_Wizard
CJ Wannabe
CJ Wannabe
Posts: 9
Joined: August 5th, 2013, 6:35 pm

Re: Script help

Post by Sheep_Wizard » September 1st, 2013, 8:37 pm

Drofder2004 wrote:
Sheep_Wizard wrote:
Drofder2004 wrote:

Code: Select all

 
 
For basic movement stuff, either use a single waittill, or use a timed wait.
 
So how would i fix this so they move back forth using a timed wait or a single waittill, I'm new to this so still learning :)
You assign a time period in the function
e.g MoveX( <distance>, <time>);

If you know how long it takes for an action to take, you can wait that amount of time.
This is a looping back and forward movement.

Code: Select all

while(1)
{
   ent_a moveX(100, 2);
   ent_b moveX(100, 2);
   wait 2;
   ent_b moveX(-100, 2);
   ent_a moveX(-100, 2);
   wait 2;
}
If you want to use "waittill" you can, but only wait for a single entity.

Code: Select all

while(1)
{
   ent_a moveX(100, 2);
   ent_b moveX(100, 2);
   ent_b waittill("movedone");
   ent_b moveX(-100, 2);
   ent_a moveX(-100, 2);
   ent_a waittill("movedone");
}
Ok, i think i understand now, thanks for your help :D :D :D :D

Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests