ZDoom. Elevator with button

And zdra-zdra-aaa-pchhi! Forgive me.

Comrade QRCODE asked how to make an elevator with a button. Download.

We draw everything as in the diagram. These are the basics of mapping, I will not dwell on this. Vadnik is available. Please note: the side inner lines are checked opposite unpegged. This is necessary in order for the texture of the walls to move along with the elevator. Based on all this, you can come up with your options.

At the sector tag I made 10, the ceiling there at a height of 128, which when you go inside looks like an elevator cabin. The button will be a line that I assigned the same tag as the sector, but it's not necessary, it's just more convenient for me. The texture on this line is the bottom is a switch. Activation – when player press use; repeatable action. It is important to make sure that the line to the player is turned by the front, that is, the flag, and then the switch will not be animated (and pressing without an additional check mark "player can use from back" will not work. On the line we had 80 Script Execute 1, but 2 scripts. Here they are:

script 1 (void) {
Elevator_RaiseToNearest(10, 64);
delay(35*3);
SetLineSpecial(10, ACS_Execute, 2);
}

script 2 (void) {
Elevator_lowerToNearest(10, 64);
delay(35*3);
SetLineSpecial(10, ACS_Execute, 1);
}

So what do they do? The first script synchronously raises the floor and ceiling (Elevator_RaiseToNearest) of sector 10 at a speed of 64. After 3 seconds (delay(35*3);) it changes the setline (SetLineSpecial) with tag 10 to activation by clicking on it script 2 (ACS_Execute, 2).

The second script does the same thing, but it lowers the floor with the ceiling (Elevator_lowerToNearest) and after 3 seconds forces the line to execute 1 script by pressing.

While the elevator is going, pressing the button does not change anything. As soon as the elevator arrives, the action of the button changes. So this (delay(35*3);) you need to adjust to the speed of your elevator and the height where it goes.

You can draw doors and add their open-close to the scripts. Functions, for example, Door_Open and Door_Close, it is no wonder to understand there, besides, the script editor itself gives hints. But if it is necessary, I will then write a tutorial on a variety of elevators with different behaviors. Or someone else will write, hey.

Why did I make 2 scripts, and not one, in which there will be something like "if sector 10 is at height 0, then lift the elevator, if it is at a height (for example) 256, then lower the elevator"? As far as I understand, this is possible, but I also wanted to show how scripts can change the lines of the rush along the tag of these lines. You can make a switch on the map, it will execute a script that will put not an elevator on this button in the elevator, but Print(s:"NO POWER");, for example. And it was so stupidly easier for me, because I am a lazy ass, and the example I showed is quite primitive compared to what comrades Bolon and Ilya can do. Something like that.

Comment, rate, subscribe, Amaranth was with you, this is the site of under-prog.ru, here we do something. Rip and tear, and good luck!

Пожалуйста отключи блокировщик рекламы, или внеси сайт в белый список!

Please disable your adblocker or whitelist this site!