Creating multiple buttons for one door: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (→‎Setting the buttons to open the door: Unicodifying, replaced: [[Image: → [[File: (6))
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{back | Portal Level Creation}}
{{lang|Creating multiple buttons for one door|title=Portal – Tutorial – Multiple Buttons For One Door}}
{{otherlang2
{{back|Portal Level Creation}}
|ru=Creating_multiple_buttons_for_one_door:ru
}}
[[Image:Multiplebuttonsresult.png|right|thumb|350px|]]
 
This tutorial will detail the basics of getting a door to open only when two (or more) buttons are activated.
This tutorial will detail the basics of getting a door to open only when two (or more) buttons are activated.


== Door, buttons and triggers ==
==Door, buttons and triggers==
Create your doorway and two buttons by following the tutorial for [[Creating a button and door|creating a button and linked door]] through step 5 of the section titled "Triggers".
Create your doorway and two buttons by following the tutorials [[Floor button]] and [[Test Chamber Door]].
{{note|Your buttons and triggers should be distinct from one another. Check all of the following on each button to make sure you have changed the '''button_*''' prefix to '''button#_*''', with # representing which button it is:
* The name of the movement door under the button (originally '''button_top_door''')
* The parent of your '''button_top_model''' (same as above)
* The name of the two triggers '''button_trigger_player''' and '''button_trigger_box'''}}


Next, complete steps 7 and 8 under [[Creating a button and door#Triggers|Triggers]] on the other tutorial for each button, making sure that you are using the appropriate '''button#_*''' prefix.
==Setting the buttons to open the door==
 
Create a [[math_counter]] entity, and put it near your door. Set the following properties:
== Setting the buttons to open the door ==
Create a [[math_counter]] entity, and put it near your door. Set the following properties:
::{| class=standard-table
::{| class=standard-table
!  Property Name || Value
!  Property Name || Value
|-
|-
| Name || buttoncounter
| Name || door_counter
|-
|-
| Maximum Legal Value || 2
| Maximum Legal Value || 2
|}
|}
For the <code>Maximum Legal Value</code> key value, you can enter whatever number you need.
Now go to the Outputs tab and set the following outputs:
Now go to the Outputs tab and set the following outputs:
::{| class=standard-table
::{| class=standard-table
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
|-
|-
| [[Image:Io11.png]] || OnHitMax || door_left || Open || <none> || 0.00 || No
| [[File:Io11.png]] || OnHitMax || door_left || Open || <none> || 0.00 || No
|-
|-
| [[Image:Io11.png]] || OnHitMax || door_right || Open || <none> || 0.00 || No
| [[File:Io11.png]] || OnHitMax || door_right || Open || <none> || 0.00 || No
|-
| [[Image:Io11.png]] || OnHitMax || buttoncounter || SetHitMin || 1 || 0.00 || No
|-
| [[Image:Io11.png]] || OnHitMin || door_left || Close || <none> || 0.00 || No
|-
| [[Image:Io11.png]] || OnHitMin || door_right || Close || <none> || 0.00 || No
|-
| [[Image:Io11.png]] || OnHitMin || buttoncounter || SetHitMin || 0 || 0.00 || No
|}
|}
Now go to each of your '''button_top_door''' brush entities and set these outputs:
Now go to each of your <code>floor_button_door</code> brush entities and set these outputs:
::{| class=standard-table
::{| class=standard-table
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
!  || My Output || Target Entity || Target Input || Parameter || Delay || Only Once
|-
|-
| [[Image:Io11.png]] || OnOpen || buttoncounter || Add || 1 || 0.00 || No
| [[File:Io11.png]] || OnOpen || door_counter || Add || 1 || 0.00 || No
|-
|-
| [[Image:Io11.png]] || OnClose || buttoncounter || Subtract || 1 || 0.00 || No
| [[File:Io11.png]] || OnClose || door_counter || Subtract || 1 || 0.00 || No
|-
| [[File:Io11.png]] || OnClose || door_left|| Close || <none> || 0.00 || No
|-
| [[File:Io11.png]] || OnClose || door_right|| Close || <none> || 0.00 || No
|}
|}


== Theory ==
The counter starts at zero.  When you activate a button by any means, the button adds 1 to the counter.  When you deactivate a button, the button subtracts 1 from the counter.  When the counter reaches the maximum value 2, it opens the door and sets the minimum value as 1.  When the counter reaches this minimum value, it closes the door and clears the minimum value.
This scenario can be easily adapted to have more requirements, different requirements, or different actions.


== See also ==
==See also==
* [[Portal Level Creation]]
* [[Portal Level Creation]]


[[Category:Level Design Tutorials]]
[[Category:Portal]]
[[Category:Portal]]
[[Category:Level Design]]
[[Category:Tutorials]]

Latest revision as of 18:21, 7 January 2024

English (en)Русский (ru)中文 (zh)Translate (Translate)
Portal Level Creation

This tutorial will detail the basics of getting a door to open only when two (or more) buttons are activated.

Door, buttons and triggers

Create your doorway and two buttons by following the tutorials Floor button and Test Chamber Door.

Setting the buttons to open the door

Create a math_counter entity, and put it near your door. Set the following properties:

Property Name Value
Name door_counter
Maximum Legal Value 2

For the Maximum Legal Value key value, you can enter whatever number you need.

Now go to the Outputs tab and set the following outputs:

My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnHitMax door_left Open <none> 0.00 No
Io11.png OnHitMax door_right Open <none> 0.00 No

Now go to each of your floor_button_door brush entities and set these outputs:

My Output Target Entity Target Input Parameter Delay Only Once
Io11.png OnOpen door_counter Add 1 0.00 No
Io11.png OnClose door_counter Subtract 1 0.00 No
Io11.png OnClose door_left Close <none> 0.00 No
Io11.png OnClose door_right Close <none> 0.00 No


See also