Page 1 of 1

Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 7:03 am
by marcello
Hello everybody, I'm having some problems with a script in a map I'm making, I'm new in mapping and it's the first time I try to create a script.

I have created an elevator using 3D floor in gzdoom builder, I've put the tag 45 on the floor, on the ceiling of the elevator.
I want that you can call the elevator with a switch and then the elevator came back to the original position after waiting for some second.

This is what I wrote:

script 8 (void)
{
Floor_LowerByValue(45,27,128);
Ceiling_LowerByValue(45,27,128);
Delay(1);
Floor_RaiseByValue(45,27,128);
Ceiling_RaiseByValue(45,27,128);
}

Repetable action;
When player presses use;

The elevator lower correct, but is not raising... What am I missing?

RE: Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 7:38 am
by ARGENTVM
You will probably have to lengthen the delay time to compensate for the Floor and Ceiling lower speed, otherwise the raise event happens too early afterwards.

RE: Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 8:21 am
by Catastrophe
instead of delay(1); use tagwait(45);

RE: Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 9:11 am
by marcello
While I was waiting I figured out:

script 8 (void)
{
{
Floor_LowerByValue(45,27,128);
Ceiling_LowerByValue(45,27,128);
Delay(1);
}
Delay(100);
{
Floor_RaiseByValue(45,27,128);
Ceiling_RaiseByValue(45,27,128);
Delay(1);
}
}

In this way it works. But I try tagwait right now! Tahnk you!

RE: Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 9:36 am
by Catastrophe
Np, also just letting you know, FloorAndCeiling_LowerByValue and FloorAndCeiling_RaiseByValue exists.

RE: Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 10:47 am
by Konda
marcello wrote: While I was waiting I figured out:

script 8 (void)
{
{
Floor_LowerByValue(45,27,128);
Ceiling_LowerByValue(45,27,128);
Delay(1);
}
Delay(100);
{
Floor_RaiseByValue(45,27,128);
Ceiling_RaiseByValue(45,27,128);
Delay(1);
}
}

In this way it works. But I try tagwait right now! Tahnk you!
tagwait is more flexible because you won't have to change the delay if you decide to alter the raise/lower speed in the future.

RE: Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 12:13 pm
by Ivan
Nobody noticed this thread being in the wrong place? There's Editing Help section for these questions.

RE: Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 12:25 pm
by Lycaon
the delay(x); thing counts tics, not seconds. 35 tics = 1 second

RE: Scripts... what the hell!!!

Posted: Fri Jul 24, 2015 12:32 pm
by Fused
Moved thread to the correct subforum.

Also, this is probably the best thing to do:

Code: Select all

script 8 (void){
    FloorAndCeiling_LowerByValue(45,27,128);
    Tagwait(45);
    Delay(35); //wait a second before actually moving up again.
    FloorAndCeiling_RaiseByValue(45,27,128);
}

RE: Scripts... what the hell!!!

Posted: Sat Jul 25, 2015 6:54 am
by marcello
Catastrophe wrote: Np, also just letting you know, FloorAndCeiling_LowerByValue and FloorAndCeiling_RaiseByValue exists.
Ah? ahahahaha! I didn't know it!!!
Konda wrote: tagwait is more flexible because you won't have to change the delay if you decide to alter the raise/lower speed in the future.
Thank you, didn't know "tagwait".
Lycaon wrote: the delay(x); thing counts tics, not seconds. 35 tics = 1 second
Ok, this information is very usefull.
Ivan wrote: Nobody noticed this thread being in the wrong place? There's Editing Help section for these questions.
Fused wrote: Moved thread to the correct subforum.
My apologies
Fused wrote: Also, this is probably the best thing to do:

Code: Select all

script 8 (void){
    FloorAndCeiling_LowerByValue(45,27,128);
    Tagwait(45);
    Delay(35); //wait a second before actually moving up again.
    FloorAndCeiling_RaiseByValue(45,27,128);
}
Works really great! Thank you everybody, I am very greteful, may I ask another question? If I want to change the brightness of a room, which script should I look for?

RE: Scripts... what the hell!!!

Posted: Sat Jul 25, 2015 7:57 am
by Fused
marcello wrote: If I want to change the brightness of a room, which script should I look for?
Light_Fade (tag, value, tics)
- tag: Tag of affected sector
- value: New light level
- tics: How long the light takes to fade to the new level

Since the thirth argument allows you to slowly fade to the desired brightness, a loop is not needed.

RE: Scripts... what the hell!!!

Posted: Sun Jul 26, 2015 6:57 am
by marcello
Ok, and if I want to coordinate a sound with the lack of light I had first to define it in SNDINFO, then I had to use "A_PlaySound" function?

RE: Scripts... what the hell!!!

Posted: Sun Jul 26, 2015 12:04 pm
by marcello
Nevermind, I don't need the answer anymore! SNDINFO, SNDSEQ, 80 script X (void) {Soundsequence ("myfile"); }

Thank you anyway!