Page 1 of 1
Script help
Posted: August 31st, 2013, 5:33 pm
by Sheep_Wizard
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");
}
}
Re: Script help
Posted: August 31st, 2013, 9:29 pm
by Drofder2004
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");
Re: Script help
Posted: September 1st, 2013, 11:34 am
by Sheep_Wizard
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

Re: Script help
Posted: September 1st, 2013, 5:30 pm
by Drofder2004
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");
}
Re: Script help
Posted: September 1st, 2013, 8:37 pm
by Sheep_Wizard
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
