how to make a door with a button

  • If you're asking a question make sure to set the thread type to be a question!

SC PL

local shitposter
aa
Jun 25, 2015
378
407
See.png


And then on map when you'll shoot at the button brush, door will open

PS: You can name door as you like, but then in func_button in a box, where is "door" text type instead a name of a door
 

sooshey

:3c
aa
Jan 7, 2015
514
410
Don't forget to set the door's open direction as "up" if you want it to open upward. It's in the keyvalues along with the door name.
 

Corfix

L1: Registered
Jan 14, 2016
29
0
i have followed your example but how do you close the door again.
is always open when you press it once
 

LeSwordfish

semi-trained quasi-professional
aa
Aug 8, 2010
4,102
6,597
Valve have been kind enough to provide us with a Close output.

If you're going to make posts this unhelpful, why bother to post at all?

To close a door, you need to send it a Close input. You can do that any way you want: you can send it from another button, or use the Delay value to close the door after a certain time.
 

Three Million

L4: Comfortable Member
Jul 2, 2015
197
75
Why doesn't someone make a vmf for @Corfix to look at and study? I would totally do it right now but I am a bit busy and afk.
 

EmNudge

L4: Comfortable Member
Sep 23, 2015
184
60
Why doesn't someone make a vmf for @Corfix to look at and study? I would totally do it right now but I am a bit busy and afk.
It's a bit late, but since he's a beginner, this may still help him.

Included is a VMF with 4 doors. Three are shown here (I'll get to the 4th one later)
f124382be22f97689fd4aebd06cb0aae.png

Door1 will open once you hit the button and it will automatically close after 3 seconds.
Door2 will open once you hit the button if it is closed and it will close once you hit the button if it is open.
Door3 will open once you hit the green button and close once you hit the red button.
For the hammer part:
door1.jpg

The button is set to open door1 when it is damaged (hit by a player)
The door has a delay of 3, so it will close after 3 seconds of being opened.
The other doors have a delay of -1, so those doors will never do anything by themselves.

door2.jpg

The button here will "toggle" door2, so it will set the door in the opposite position of what it's in.
For example, if it is open the button will close it and if it is closed the button will open it.

door3.jpg

This door has 2 buttons. One that opens it (green ones) and one that closes it (red one).

Finally, we move on to #4, which is slightly more advanced.
door4.jpg

Door 4 does the same thing as Door 2, except it lets the user use the +use command (which is disabled by default anyway).
We have "Damage Activates" Checked and use OnPressed instead of OnDamaged since damage will activate it, but so will +use.
To use the command, you first must enable it in console with
Code:
tf_allow_player_use 1
and then bind it to a key. EX:
Code:
 bind O +use
See the video for a better understanding.

Cheers!
 

Attachments

  • door_TEST.vmf
    38.2 KB · Views: 141
  • door_TEST.vmf
    38.2 KB · Views: 166
Last edited:

Moth

L2: Junior Member
Jul 3, 2016
82
247
super nice Em, this is really useful for lazy hammer logic illiterate peaple like me.