PDA

View Full Version : Timed Door



wannabe
6th March 2014, 15:50
Hello!

I just need some help here. I'm making a timed door (a door that opens at a exact time, example when time hits 20 mins left, the door will open automatic.) I have no idea how to make it, but i was hoping one of you guys might know how to. I was on a other webpage someone told me about, but absolutely everything was on polish, and i don't know any polish at all. If so, can someone make me a tutorial how to? With scripts if possible.

Cheers!

Ni3ls
6th March 2014, 16:23
Just make a the easiest timer

t=0;
while(1)
{
if(t==10)
{
doscriptwithdoor
}
t++;
wait 60;
}

something like that

wannabe
6th March 2014, 16:29
And in radiant, does i have to be a brushmodel there?

Ni3ls
6th March 2014, 19:11
Just make a normal door etc. And you place this in ur mp_mapname.gsc. It will be the same as a normal door script, but now with a timer

wannabe
6th March 2014, 19:13
Ill try and i will report back

wannabe
6th March 2014, 19:56
But i know something. Like i want like a double door, that opens and one part goes to the right, and the other part will go the the left. like this:
662663

wannabe
6th March 2014, 19:58
All i problaby need now is something like this:
main()
{
something = getEnt("something", "targetname");

angle = 90; // 4 times = one full round
seconds = 1;

while (1)
{
for (i=0; i<4; i++)
{
iprintlnbold("rotateYaw " + i); // 0,1,2,3 = 4
something rotateYaw(angle, seconds);
something waittill("rotatedone");
}
From http://killtube.org/showthread.php?359-VIDEO-rotating-brushmodels

Just that it takes 10 mins before it starts opening. and it rotates just 90 degrees and stops

pollo
6th March 2014, 20:18
Make 2 brushes that will be the doors you want to open.


Make 2 brushes with 'origin' tool texture that will be the ''axis'' where the door will rotate on.

664

Make each door script_brushmodel (with its origin brush too), like this:

665

666

Now copy this script (change values if needed)


main()
{
door1= getent("lol1","targetname");
door2= getent("lol2","targetname");
t=0;

while(1)
{
if(t==10)
{
door1 rotateyaw(90,2);
door2 rotateyaw(-90,2);
door2 waittill("rotatedone");
}
t++;
wait 60;
}
}

wannabe
7th March 2014, 14:03
I cant see the pictures, but i get what you mean.
In "n" Entity

Key: targetname
Value: door1/door2

Is that right?

wannabe
7th March 2014, 15:43
There is a error with the script. It says like:
door1 rotateyaw(90,2);
door2 rotateyaw(-90,2);
door2 waittill("rotatedone");
} < < < < <
t++;
wait 60;
}
}

Watch arrows "<" hmm, i dont understand it, i dont see what the problem with } is ^^

Tally
7th March 2014, 16:06
There is a sticky that says when asking about errors always post the code. We can't see what the error is unless you post your code. We are not mind readers.

wannabe
7th March 2014, 16:33
Well, here it is:


******script compile error******
bad syntax: (file 'maps/mp/castle.gsc', line 15
}
*
***********************************

And script is:

main()
{
door1= getent("lol1","targetname");
door2= getent("lol2","targetname");
t=0;

while(1)
{
if(t==10)
{
door1 rotateyaw(90,2);
door2 rotateyaw(-90,2);
door2 waittill("rotatedone");
iPrintInBold("Castle Opened!")
}
t++;
wait 10;
}
}

Ni3ls
7th March 2014, 17:45
iPrintInBold("Castle Opened!") Missing the ";"

Tally
7th March 2014, 21:10
main()
{
door1= getent( "lol1", "targetname" );
door2= getent( "lol2", "targetname" );
t = 0;

while( true )
{
if( t == 10 )
{
door1 rotateyaw( 90, 2 );
door2 rotateyaw( -90, 2 );
door2 waittill( "rotatedone" );
iPrintInBold( "Castle Opened!" );
}

t++;

wait 10;
}
}


You do know that once the doors are open, the loop will carry on? The doors will keep rotating their yaw again and again and again. If you only want them to open once, you need to break from the loop once done.

YuriJurek
7th March 2014, 21:28
main()
{
door1= getent( "lol1", "targetname" );
door2= getent( "lol2", "targetname" );
t = 0;

while( true )
{
if( t == 10 )
{
door1 rotateyaw( 90, 2 );
door2 rotateyaw( -90, 2 );
door2 waittill( "rotatedone" );
iPrintInBold( "Castle Opened!" );
}

t++;

wait 10;
}
}


You do know that once the doors are open, the loop will carry on? The doors will keep rotating their yaw again and again and again. If you only want them to open once, you need to break from the loop once done.

Just do
main()
{
door1 = getent( "lol1", "targetname" );
door2 = getent( "lol2", "targetname" );

wait(60 * 10);
door1 rotateyaw( 90, 2 );
door2 rotateyaw( -90, 2 );
door2 waittill( "rotatedone" );
iPrintInBold( "Castle Opened!" );
}

Waaay less complicated and doesn't involve any loops.

wannabe
8th March 2014, 18:48
Yuri, it says that the line 10, which is the:
main()
{
door1 = getent( "lol1", "targetname" );
door2 = getent( "lol2", "targetname" );

wait(60 * 10);
door1 rotateyaw( 90, 2 );
door2 rotateyaw( -90, 2 );
door2 waittill( "rotatedone" );
iPrintInBold( "Castle Opened!" );
}
That the iPrintInBold is invalid, with


*********************
script compile error

maps/mp/castle.gsc, line 10

*
*********************

wannabe
8th March 2014, 18:55
But i deleted it, and it works then so

wannabe
8th March 2014, 19:02
But this does not open my doors at all. i can post some screenshots if you want

YuriJurek
8th March 2014, 21:14
See the error is someone posted it with an I instead of L "iPrintlnBold" try that:
iprintLnbold( "castle opened!" );

It was upper case i and not L lower in that place.

wannabe
8th March 2014, 21:25
Okey. But I'm getting help from Roman, Yuri

pollo
9th March 2014, 20:20
Replace the

door2 waittill("rotatedone");

to

break;

Like this:


if(t==10)
{
door1 rotateyaw(90,2);
door2 rotateyaw(-90,2);
break;
}
t++;
wait 60;

Also, you must finish each line with '';''

Thats why you got the previous error xD

wannabe
11th March 2014, 19:32
Ok, Pollo, but i changed my mind a little. A two door entrance is just so hard to get working properly, so i decided that only one of them will open so the castle will just be half opened ;)

wannabe
11th March 2014, 19:36
But can i ask, what is the "if(t==10)" and "t++;" for?

wannabe
11th March 2014, 20:20
But I got some help by a friend, but i haven't heard from him in two days. The problem is still that the doors doesn't open at all, sot even a sign of it..

Tally
11th March 2014, 21:31
But I got some help by a friend, but i haven't heard from him in two days. The problem is still that the doors doesn't open at all, sot even a sign of it..

Check your target names. Make sure the code is detecting the right target name. The code itself is sound - it should work as intended.

wannabe
12th March 2014, 18:25
In radiant:
Key: targetname
Value: lol1
In gsc-file:
targetname and lol1 and lol2


Nothing wrong as far i can see..

Ni3ls
13th March 2014, 15:16
Show your gsc file

wannabe
13th March 2014, 18:08
The mp_hs.gsc:


main()
{
maps\mp\_load::main();
maps\mp\teleportenter::main();
maps\mp\logo::main();
maps\mp\castle::door();

setExpFog(0.0001, 0.55, 0.6, 0.55, 0);
// setCullFog(0, 16500, 0.55, 0.6, 0.55, 0);
ambientPlay("ambient_france");

game["allies"] = "american";
game["axis"] = "german";
game["attackers"] = "allies";
game["defenders"] = "axis";
game["american_soldiertype"] = "normandy";
game["german_soldiertype"] = "normandy";

setCvar("r_glowbloomintensity0", ".25");
setCvar("r_glowbloomintensity1", ".25");
setcvar("r_glowskybleedintensity0",".3");

}

The "castle/door" file:


door()
{
door1= getent( "lol1", "targetname" );
door2= getent( "lol2", "targetname" );
t = 0;

while( true )
{
if(t==10)
{
door1 rotateyaw(90,2);
door2 rotateyaw(-90,2);
break;
}
t++;
wait 60;
}

}

Ni3ls
13th March 2014, 18:56
put thread in front of all your custom scripts
thread maps/mp etc

wannabe
13th March 2014, 19:25
Hmm, i'm not sure what you mean with that, can you specify?

pollo
16th March 2014, 15:10
But can i ask, what is the "if(t==10)" and "t++;" for?


while( true )
{
if(t==10) //if "time" variable is equal to 10 (minutes)
{
//do this
door1 rotateyaw(90,2);
door2 rotateyaw(-90,2);
break;
}
t++; //add a minute to "time" variable
wait 60; //waits 60 seconds and restarts the loop if t (time variable) is not 10
}

----------------------------------------------------


Hmm, i'm not sure what you mean with that, can you specify? (thread)

thread: carries out a function independently of other functions

For example:


blas1();
blas2();
blas3();

blas3(); will be carried out after the end of the blas2(); function, and this one will be carried out after the end of blas1();


thread blas1();
thread blas2();
thread blas3();

blas1(); blas2(); blas3(); will carry out at the same time.

wannabe
17th March 2014, 20:35
Okey pollo. But i decided to close this project i have right now. So i will see later if i come back to it. Thanks for the support guys!