Puzzle for infiltration/hiest game: reactivate deactivated lift (sugarcube)

0 votes
asked May 11 by PapaPalpatine (110 points)
In the building the player is infiltrating, the lift (elevator) is deactivated and all the stairwells are being patrolled by armed guards who have orders to arrest (or shoot) any unauthorized persons the catch trying to take the stairs. The puzzle for the player would consist of trying to reactivate the lift by reconnecting three wires in the correct sequence. If they get the sequence right, the lift becomes functional and allows them to bypass the guards in the stairwells. If they get the sequence wrong it either won't work or, in the worst case scenario, will trigger the alarm system. Any suggestions on coding the puzzle?

1 Answer

+1 vote
answered May 12 by greyelf (83,590 points)

Please use the Question Tags to state the name and full version number of the Story Format you are using, as answers can vary based on that information. I will assume you are using SugarCube v2.21.0 or later.

I suggest use an Array and store the name of each wire in it as it is connected, this will allow you to check the order of those names.

The following rough prototype includes links for connecting each of three coloured wires, for testing if all three have been connected and that they were connected in the correct order. It also has a link for resetting / un-connecting all the wires.

<<set $connected to []>>\
Message: @@#message;No wires are connected.@@

<<link "Connect Red Wire">>
	<<run $connected.pushUnique("Red")>>

<<link "Connect Green Wire">>
	<<run $connected.pushUnique("Green")>>

<<link "Connect Blue Wire">>
	<<run $connected.pushUnique("Blue")>>

Determine if all three wires have need connected and that they were connects in the order of Red, Green, Blue.\

<<link "Test Connections">>
	<<if $connected.length lt 3>>
		<<replace "#message">>You need to connect all three wires.<</replace>>

	<<elseif $connected[0] is "Red"
				and $connected[1] is "Green"
				and $connected[2] is "Blue">>
		<<replace "#message">>The wires are connect correctly.<</replace>>

		<<replace "#message">>The wires were not connected in the right order.<</replace>>

<<link "Reset all connections">>
	<<set $connected to []>>
	<<replace "#message">>No wires are connected.<</replace>>

I suggest you read the relevant SugarCube 2.x documentation for any of the above macros or functions you're not familiar with.

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.