<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3ATutorials%3Ascript%3Abuttons_that_open_a_door</id>
	<title>Hpl2:Tutorials:script:buttons that open a door - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.frictionalgames.com/page?action=history&amp;feed=atom&amp;title=Hpl2%3ATutorials%3Ascript%3Abuttons_that_open_a_door"/>
	<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:buttons_that_open_a_door&amp;action=history"/>
	<updated>2026-05-14T03:55:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:buttons_that_open_a_door&amp;diff=844&amp;oldid=prev</id>
		<title>Maintenance script: Upload from wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.frictionalgames.com/page?title=Hpl2:Tutorials:script:buttons_that_open_a_door&amp;diff=844&amp;oldid=prev"/>
		<updated>2020-07-09T13:48:46Z</updated>

		<summary type="html">&lt;p&gt;Upload from wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Buttons that opens a door =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Today I (xtron) will teach you (the reader) how to make lets say press 4 buttons and a door opens.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First off you will be needing THE DOOR!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''THE DOOR:''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Press on entities (7) &amp;gt; Doors &amp;gt; Choose the door of your liking and place it out on your map. Change the name of your door to door1.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now if you want it be unlock itself when you pressed those magic buttons you will need to lock it!.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the door you just created &amp;gt; Entity &amp;gt; Check the Lock box.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you're done with adding the door, lets add some buttons then!.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''THE BUTTONS:''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Press on entities (7) &amp;gt; Gameplay &amp;gt; Press on button_simple and place out how buttons you want the player to press and rename the buttons to your liking, for example: button1, button2 , button3 etc…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you're done with adding the buttons, we can finally go to the scripting part! yeeey!.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''THE SCRIPT:''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Lets say that you want the player to press 4buttons and then a door unlocks itself and opens a bit.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add this to your void OnStart()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
SetLocalVarInt(&amp;quot;Var1&amp;quot;, 0);&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;button1&amp;quot;, &amp;quot;func1&amp;quot;, true);&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;button2&amp;quot;, &amp;quot;func2&amp;quot;, true);&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;button3&amp;quot;, &amp;quot;func3&amp;quot;, true);&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;button4&amp;quot;, &amp;quot;func4&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you're done adding that you can start adding the functions which looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void func1(string &amp;amp;in asEntity)&lt;br /&gt;
{&lt;br /&gt;
AddLocalVarInt(&amp;quot;Var1&amp;quot;, 1);&lt;br /&gt;
func5();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func2(string &amp;amp;in asEntity)&lt;br /&gt;
{&lt;br /&gt;
AddLocalVarInt(&amp;quot;Var1&amp;quot;, 1);&lt;br /&gt;
func5();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func3(string &amp;amp;in asEntity)&lt;br /&gt;
{&lt;br /&gt;
AddLocalVarInt(&amp;quot;Var1&amp;quot;, 1);&lt;br /&gt;
func5();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func4(string &amp;amp;in asEntity)&lt;br /&gt;
{&lt;br /&gt;
AddLocalVarInt(&amp;quot;Var1&amp;quot;, 1);&lt;br /&gt;
func5();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func5()&lt;br /&gt;
{&lt;br /&gt;
if(GetLocalVarInt(&amp;quot;Var1&amp;quot;) == 4)&lt;br /&gt;
    {&lt;br /&gt;
/////add what ever you want to happen after you press all 4 buttons here.&lt;br /&gt;
    SetSwingDoorLocked(&amp;quot;door1&amp;quot;, false, false);&lt;br /&gt;
    PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;unlock_door.snt&amp;quot;, &amp;quot;door1&amp;quot;, 0.5f, false);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can change the function names and the door name to whatever you chosen and/or you want it to be.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When you successfuly managed to add this in to your .hps file it should look something like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot;&amp;gt;void OnStart()&lt;br /&gt;
{&lt;br /&gt;
SetLocalVarInt(&amp;quot;Var1&amp;quot;, 0);&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;button1&amp;quot;, &amp;quot;func1&amp;quot;, true);&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;button2&amp;quot;, &amp;quot;func2&amp;quot;, true);&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;button3&amp;quot;, &amp;quot;func3&amp;quot;, true);&lt;br /&gt;
SetEntityPlayerInteractCallback(&amp;quot;button4&amp;quot;, &amp;quot;func4&amp;quot;, true);&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func1(string &amp;amp;in asEntity)&lt;br /&gt;
{&lt;br /&gt;
AddLocalVarInt(&amp;quot;Var1&amp;quot;, 1);&lt;br /&gt;
func5();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func2(string &amp;amp;in asEntity)&lt;br /&gt;
{&lt;br /&gt;
AddLocalVarInt(&amp;quot;Var1&amp;quot;, 1);&lt;br /&gt;
func5();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func3(string &amp;amp;in asEntity)&lt;br /&gt;
{&lt;br /&gt;
AddLocalVarInt(&amp;quot;Var1&amp;quot;, 1);&lt;br /&gt;
func5();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func4(string &amp;amp;in asEntity)&lt;br /&gt;
{&lt;br /&gt;
AddLocalVarInt(&amp;quot;Var1&amp;quot;, 1);&lt;br /&gt;
func5();&lt;br /&gt;
}&lt;br /&gt;
 &lt;br /&gt;
void func5()&lt;br /&gt;
{&lt;br /&gt;
if(GetLocalVarInt(&amp;quot;Var1&amp;quot;) == 4)&lt;br /&gt;
    {&lt;br /&gt;
/////add what ever you want to happen after you press all 4 buttons here.&lt;br /&gt;
    SetSwingDoorLocked(&amp;quot;door1&amp;quot;, false, false);&lt;br /&gt;
    PlaySoundAtEntity(&amp;quot;&amp;quot;, &amp;quot;unlock_door.snt&amp;quot;, &amp;quot;door1&amp;quot;, 0.5f, false);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now. When the map loads Var1 will start with a count on 0 ( SetLocalVarInt(&amp;quot;var1&amp;quot;, 0); ). Everytime you press a button the funcs will&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
turn active and it adds 1 to the Var1 count, so if you press button1 Var1 will go from 0 to 1 and then you press button2 and Var1 will go&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
from 1 to 2 and so on until it reaches count 4 then func5 will occur and SetSwingdoorLocked will happen and PlaySoundAtEntity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I hope you understand it and if you got any questions or requests on what I should show or how I should make my tutorials please send a&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
PM on Frictionalgames forum and I'll be glad to change it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;Thanks for reading!&amp;lt;/u&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''by xtron''&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
		
	</entry>
</feed>