Combination Locks
This is a modification of a Dromed Central tutorial.
First, create several items:
one physical→Gizmo→Gauge→Odometer
one physical→Gizmo→Switches→Buttons→NumberButton. The others can be added once this one has had some properties set.
one fnord→TrapTrig→QuestVarTrigger
-
After placing these in a level, we do the following.
Add the property Trap→QuestVar to the Odometer and give it the argument door_combo
Do the same for the NumberButton
Add the property Shape→TxtRepl r0 to the NumberButton. The argument for this is obj\txt16\button0
To make the rest of your buttons, clone this one and change the TxtRepl r0 argument to button1, button2, button3, etc.
Add the property Trap→QuestVar to the QuestVarTrigger and give it the argument “1138:door_combo (YES, a QUOTE goes to the beginning but not the end! Kinda like cheap French literature.)
OBVIOUSLY, you should replace 1138 with the combination you want to use, or we’ll have the combination 1138 in every fan mission…
The “ means that the quest variable door_combo should end with 1138, which allows for the player trying other numbers beforehand.
Add a ControlDevice link from the QuestVarTrigger to the item you want to control with the code.
Type the command quest_create_mis door_combo, 0
The combination lock should now be fully functional.
You will notice there are no ControlDevice links between the NumberButtons and the Odometer. This is because the buttons inherit the NumberButton script from the hierarchy, and that script looks at the texture to work out which number has been entered.
If you want to have multiple independent combination locks, do the above steps again but instead of typing door_combo, type something else (door_combo is just a variable name, there’s nothing special about it).