Jump to content

Home

Complex Doors/Button Advice


Recommended Posts

In a room I have 6 stones that act as buttons. When 3 specific buttons are forced pushed they indent further into the wall and open a secret door in the same room. I only want those 3 buttons to open the door because they act as a combination code. And I want any false code to open a trap door.

 

Now I have the correct "combination code" working (the easy part) with the following method --> I made the buttons into func_doors with the following keys and values:

 

key: target

value: button01

 

Next I made a target_counter with the following keys and values:

 

key: count

value: 3

key: target

value: door01

key: targetname

value: button01

 

This linked everything together and it works great.

 

Okay here is my dilemma.

 

Since there can be numerous "false codes" I believe that a script will be more efficient then creating several methods like above to open the trap door. I figure the script can use an IF ELSE statement to accomplish this.

 

Now what I need is some advice on how to go about writing this script so this "puzzle room" works properly. Thank you for your advice, tips, hints, etc.

Link to comment
Share on other sites

Sure thing I'll post the solution shortly, after a making few comments. First of all I would like to say that reading over the manual did help. It also helps to have some knowledge about coding in general and the concepts of if statements. In addition, looking through the SP scripts helps alot.

Link to comment
Share on other sites

To recap I have a room that has 6 buttons. These buttons act as a combination code. There are 3 "correct" buttons and 3 "incorrect" buttons. Only when all 3 correct buttons are forced pushed a secret door opens in the same room. And any combination of "incorrect" buttons with 0, 1, or 2 correct buttons will open a trap door plummeting the player to an untimely death...hehehe

 

In Radiant I made the 6 buttons func_doors because I want them to move when forced pushed. Then I made both door brushes. Next I made 2 origin brushes and placed them inside the door brushes. With a door brush and origin brush selected I made them into func_statics. Inside my secret and trap doors are ref_tags that are referenced inside the scripts. The 3 correct buttons have these keys and values:

 

Key: target

Value: correct

Key: wait

Value: -1

 

Now a target_scriptrunner targets these "correct" buttons and has these keys and values:

 

Key: targetname

Value: correct

Key: count

Value: -1

Key: Usescript

Value: resurgence/correct_combo

 

So whenever a "correct" button is pushed it'll run this script:

 

//Generated by BehavEd

 

rem ( "correct_combo.IBI");

rem ( "Puzzle Room Script" );

rem ( "Script by: Obsidian-Jovani" );

rem ( "Declare the variable correct_combo" );

declare ( /*@DECLARE_TYPE*/ FLOAT, "correct_combo" );

rem ( "When the correct symbol is pushed increment the count" );

set ( "correct_combo", "+1" );

rem ( "Run incorrect_combo script to see if correct button is part of a false code" );

run ( "resurgence/incorrect_combo" );

rem ( "If 3 true and 0 false open secretdoor" );

 

if ( $get( FLOAT, "correct_combo") = 3$ )

{

 

affect ( "secretdoor", FLUSH )

{

move ( $tag("secretdoor_open", ORIGIN)$, $< 0 0 0 >$, 5000.000 );

wait ( -1.000 );

}

 

}

 

The remarks explain what is going on. Basically it increments the count +1 and runs a second script in case a correct button is the 3rd button pushed in a false code. After the 2nd script finishes running the flow returns to the 1st script by checking to see if the correct count = 3. If so open the secret door. Here is the second script:

 

//Generated by BehavEd

 

rem ( "incorrect_combo.IBI");

rem ( "Puzzle Room Script" );

rem ( "Script by: Obsidian-Jovani" );

rem ( "Perform series of checks to see if true" );

rem ( "if 1 false and 2 true open trapdoor" );

 

if ( $get( FLOAT, "incorrect_combo") = 1$ )

{

 

if ( $get( FLOAT, "correct_combo") = 2$ )

{

 

affect ( "trapdoor", FLUSH )

{

move ( $tag("trapdoor_open", ORIGIN)$, $< 0 0 0 >$, 1000.000 );

wait ( -1.000 );

}

 

}

 

}

 

rem ( "if 2 false and 1 true open trapdoor" );

 

if ( $get( FLOAT, "incorrect_combo") = 2$ )

{

 

if ( $get( FLOAT, "correct_combo") = 1$ )

{

 

affect ( "trapdoor", /*@AFFECT_TYPE*/ FLUSH )

{

move ( $tag("trapdoor_open", ORIGIN)$, $< 0 0 0 >$, 1000.000 );

wait ( -1.000 );

}

 

}

 

}

 

rem ( "if 3 false and 0 true open trapdoor" );

 

if ( $get( FLOAT, "incorrect_combo") = 3$ )

{

 

affect ( "trapdoor", /*@AFFECT_TYPE*/ FLUSH )

{

move ( $tag("trapdoor_open", ORIGIN)$, $< 0 0 0 >$, 1000.000 );

}

 

}

 

rem ( "if 1 true and 2 false open trapdoor" );

 

if ( $get( FLOAT, "correct_combo") = 1$ )

{

 

if ( $get( FLOAT, "incorrect_combo") = 2$ )

{

 

affect ( "trapdoor", FLUSH )

{

move ( $tag("trapdoor_open", ORIGIN)$, $< 0 0 0 >$, 1000.000 );

wait ( -1.000 );

}

 

}

 

}

 

rem ( "if 2 true and 1 false open trapdoor" );

 

if ( $get( FLOAT, "correct_combo") = 2$ )

{

 

if ( $get( FLOAT, "incorrect_combo") = 1$ )

{

 

affect ( "trapdoor", FLUSH )

{

move ( $tag("trapdoor_open", ORIGIN)$, $< 0 0 0 >$, 1000.000 );

wait ( -1.000 );

}

 

}

 

}

 

As you can see it performs a series of if statements to check if the trapdoor should open and with which condition.

 

The 3 incorrect buttons have these keys and values:

 

Key: target

Value: incorrect

Key: wait

Value: -1

 

Now a target_scriptrunner targets these "incorrect" buttons and has these keys and values:

 

Key: targetname

Value: incorrect

Key: count

Value: -1

Key: Usescript

Value: resurgence/increment_incorrect

 

So whenever an "incorrect" button is pushed it'll run the 3rd script:

 

//Generated by BehavEd

 

rem ( "increment_incorrect.IBI");

rem ( "Puzzle Room Script" );

rem ( "Script by: Obsidian-Jovani" );

rem ( "Declare the variable incorrect_combo" );

declare ( /*@DECLARE_TYPE*/ FLOAT, "incorrect_combo" );

rem ( "When an incorrect symbol is pushed increment the count" );

set ( "incorrect_combo", "+1" );

run ( "resurgence/incorrect_combo" );

 

This simple script simply increments the incorrect count +1 and runs the 2nd script posted above.

 

All of this looks complicated as hell, but it is rather simple. If you have questions let me know.

 

*Note*

=====

For some reason this message board removes the spaces in the script so the brackets are not lined up properly.:mad:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...