Next revision | Previous revision | ||
hpl2:tutorials:script:buttons_that_open_a_door [2011/07/13 23:42] xtron created |
hpl2:tutorials:script:buttons_that_open_a_door [2013/05/24 11:10] (current) grunt44432 |
||
---|---|---|---|
Line 2: | Line 2: | ||
- | Today I (xtron) will teach you (the reader) how to make lets say press 3buttons and a door opens, or press 2buttons and a secret bookshelf opens. | + | Today I (xtron) will teach you (the reader) how to make lets say press 4 buttons and a door opens. |
Line 26: | Line 26: | ||
- | Press on entities (7) > Gameplay > 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... | + | Press on entities (7) > Gameplay > 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… |
Line 42: | Line 42: | ||
<code cpp> | <code cpp> | ||
- | |||
- | |||
SetLocalVarInt("Var1", 0); | SetLocalVarInt("Var1", 0); | ||
- | |||
- | |||
SetEntityPlayerInteractCallback("button1", "func1", true); | SetEntityPlayerInteractCallback("button1", "func1", true); | ||
- | |||
- | |||
SetEntityPlayerInteractCallback("button2", "func2", true); | SetEntityPlayerInteractCallback("button2", "func2", true); | ||
- | |||
- | |||
SetEntityPlayerInteractCallback("button3", "func3", true); | SetEntityPlayerInteractCallback("button3", "func3", true); | ||
- | |||
- | |||
SetEntityPlayerInteractCallback("button4", "func4", true); | SetEntityPlayerInteractCallback("button4", "func4", true); | ||
</code> | </code> | ||
Line 63: | Line 53: | ||
- | <code cpp> | + | <code cpp>void func1(string &in asEntity) |
- | void func1(string &in asEntity) | + | |
{ | { | ||
AddLocalVarInt("Var1", 1); | AddLocalVarInt("Var1", 1); | ||
func5(); | func5(); | ||
} | } | ||
- | + | ||
void func2(string &in asEntity) | void func2(string &in asEntity) | ||
{ | { | ||
Line 76: | Line 64: | ||
func5(); | func5(); | ||
} | } | ||
- | + | ||
void func3(string &in asEntity) | void func3(string &in asEntity) | ||
{ | { | ||
Line 83: | Line 70: | ||
func5(); | func5(); | ||
} | } | ||
- | + | ||
void func4(string &in asEntity) | void func4(string &in asEntity) | ||
{ | { | ||
Line 90: | Line 76: | ||
func5(); | func5(); | ||
} | } | ||
- | + | ||
void func5() | void func5() | ||
{ | { | ||
Line 110: | Line 95: | ||
- | <code cpp> | + | <code cpp>void OnStart() |
- | void OnStart() | + | |
{ | { | ||
SetLocalVarInt("Var1", 0); | SetLocalVarInt("Var1", 0); | ||
Line 119: | Line 103: | ||
SetEntityPlayerInteractCallback("button4", "func4", true); | SetEntityPlayerInteractCallback("button4", "func4", true); | ||
} | } | ||
- | + | ||
void func1(string &in asEntity) | void func1(string &in asEntity) | ||
{ | { | ||
Line 126: | Line 109: | ||
func5(); | func5(); | ||
} | } | ||
- | + | ||
void func2(string &in asEntity) | void func2(string &in asEntity) | ||
{ | { | ||
Line 133: | Line 115: | ||
func5(); | func5(); | ||
} | } | ||
- | + | ||
void func3(string &in asEntity) | void func3(string &in asEntity) | ||
{ | { | ||
Line 140: | Line 121: | ||
func5(); | func5(); | ||
} | } | ||
- | + | ||
void func4(string &in asEntity) | void func4(string &in asEntity) | ||
{ | { | ||
Line 147: | Line 127: | ||
func5(); | func5(); | ||
} | } | ||
- | + | ||
void func5() | void func5() | ||
{ | { | ||
Line 161: | Line 140: | ||
- | Now. When the map loads Var1 will start with a count on 0 ( SetLocalVarInt("var1", 0); ). Everytime you press a button the funcs will | + | Now. When the map loads Var1 will start with a count on 0 ( SetLocalVarInt("var1", 0); ). Everytime you press a button the funcs will |
- | 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 | + | 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 |