Making a Combination Lock

From FleshWorks

Jump to: navigation, search

by Rantako


Image:Making_a_Combination_Lock1.jpg

This tutorial will show you how to make a working combination lock in T3Ed. The lock itself is a relatively simple one compared to the ones found in the T2 OMs (though it still takes ages to make).

Usually, combination locks use numbers (or even letters), but since there are no number textures in T3, I’ve had to use shapes instead. There are four shapes of button all the same size – diamond, square, round and triangle. So using a four digit combination of these four shapes, we can get (correct me if I’m wrong) 256 combinations. It would of course be possible to make custom number textures, but this thing takes insanely long to make as it is.

This lock works like the one in the T2 FM Inverted Manse: you select which digit to change using the four big buttons, the light for the selected one turns on, then you change its shape using the four small buttons. Frobbing the lever next to the door checks if the combination is correct – if it is not, you hear the sound of electricity turning off, and nothing else happens. If it is correct, the red light over the door turns off, the green one next to it turns on, a sound is played, and the door opens.


Contents

Changes to Gamesys

First we will make all the changes we need to the Gamesys.


Lights

Create two new classes under Actor -> WorldObj -> Light_ -> ElectricLight -> ElecLamp -> ElecSteamLightbulb. Call the first one ElecSteamLightbulbRed and give it the following properties:

  • Lighting -> LightColor -> LightBrightness: 109, LightHue: 9, LightSaturation: 251
  • Render -> ObjectMesh: STMiLIGHTbulb (Default)

This is the red light over the door in the picture.


Call your second archetype ElecSteamLightbulbGreen and give it these properties:

  • Lighting -> LightColor -> LightBrightness: 99, LightHue: 94, LightSaturation: 189
  • Render -> ObjectMesh: STMiLIGHTbulb (Default)

This is the green light over the door in the picture (the one that's turned off).


Now create a new archetype under your ElecSteamLightbulbRed and call it ElecSteamLightbulbRedSmall'. Give it the following properties:

  • Lighting -> LightShape -> LightRadius: 10
  • Scripts -> bEnableScriptInherit: False

This is the lights to indicate which digit is selected.


Buttons

For this we need to modify some existing archetypes – of the five shapes of button, only two are as we want them (diamond and square). I don’t think the circle, triangle or rectangle ones were ever used in the game, so it should be safe to modify them, but if you are the extra-careful type you could make a new archetype under each of them and make the changes to those instead.

We want our buttons to all make the same noise (I used Medium 1, the sound made by the diamond and square ones). Go to the RoundButton under Actor -> WorldObj -> Environmental -> Switch and open up its Scripts -> TriggerScripts property. You will see it has ButtonPush and ButtonLightSound1. Select ButtonLightSound1 and change it to ButtonMediumSound1.

Unfortunately the triangle button needs a bit more work. Give it the property Scripts -> TriggerScripts and add the scripts GenericFrob, ButtonPush and ButtonMediumSound1.

The rectangle button already works. It is a much bigger button, and so has different sounds. If you look at its scripts you will see it has ButtonPush and ButtonHeavySound2. I think the sound Heavy 1 sounds better, and so changed that script to ButtonHeavySound1, but this is a matter of personal preference and not essential.

Finally, go to the archetype Actor -> WorldObj -> Environmental -> Moving -> AttachmentSliding -> DiamondButtonMover and make it placeable (right click -> Placeable/UnPlaceable).

You should save the gamesys now.


Building the Lock

Make two rooms of any size and connect them with a doorway (8 feet x 4 feet). Place a door in the doorway – the archetype Actor -> WorldObj -> Moving -> Hinged -> DoorHinged -> DoorMetalHinged -> CemMetalDoor is good because it has no handle, and we want our door to open automatically. Give your concrete door the property:

  • Highlight -> HighlightDist: 0


Place an Actor -> WorldObj -> Environmental -> Switch -> WallSwitch2 on the wall next to the door.

Place an ElecSteamLightbulbRed above the door and give it the properties:

  • Lighting -> bLightOn: True
  • Scripts -> bEnableScriptInherit: False


Place an ElecSteamLightbulbGreen next to the ElectSteamLightbulbRed, above the door. Give it the properties:

  • Lighting -> bLightOn: False
  • Scripts -> bEnableScriptInherit: False


Place a DiamondButton, a SquareButton, a RoundButton and a TriangleButton and arrange them in a row. These will be used to input the combination. Place 4 ElecSteamLightbulbRedSmall and give them all the property Lighting -> bLightOn: False. Place four RectangleButtons. Place four DiamondButtonMovers and give each of them the property Render -> DrawScale: 2.0. Arrange all these actors so they look something like this:

Image:Making_a_Combination_Lock2.jpg

(The wiring is simply for decoration)


The Indicator Lights

We need to make the four ElecSteamlightbulbRedSmalls (I’ll refer to these as the indicator lights) turn on and off as the RectangleButtons are pressed, so we know which indicator is currently selected.

First we must create four new flags. Open the Flag List (View -> Global Variables -> Flags) and create four flags called CombLock_Selected1, CombLock_Selected2, CombLock_Selected3 and CombLock_Selected4. Now open the Trigger Script Manager. It would be a good idea to create a group for CombinationLock scripts, as we will have a total of 35 new scripts (!) by the end of this tutorial (luckily, a lot of them are very similar, so you can copy them). Create the following scripts:


CombLock_Selected1

Script

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player

Image:action_icon.png ACTIONS

Image:action_icon.png Set flag [CombLock_Selected1] to [TRUE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Selected2

Script

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player

Image:action_icon.png ACTIONS

Image:action_icon.png Set flag [CombLock_Selected1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected2] to [TRUE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Selected3

Script

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player

Image:action_icon.png ACTIONS

Image:action_icon.png Set flag [CombLock_Selected1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected3] to [TRUE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Selected4

Script

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player

Image:action_icon.png ACTIONS

Image:action_icon.png Set flag [CombLock_Selected1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Set flag [CombLock_Selected4] to [TRUE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


Minimize the Trigger Script Manager for now. Give your four RectangleButtons the property Scripts -> TriggerScripts,. Give the first button from the left the script CombLock_Selected1, the second button the script CombLock_Selected2, the third button the script CombLock_Selected3, and the last button the script CombLock_Selected4. (From now on when I speak about ‘first’, ‘second’, ‘third’ and ‘fourth’ of something, I always mean from the left)

Time for 8 more scripts! Create the following scripts (you should put them in a group under CombinationLock called IndicatorLights):


CombLock_Light1Off

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When [CombLock_Selected1] is set to [FALSE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [bLightOn] to [FALSE] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions


CombLock_Light2Off

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When [CombLock_Selected2] is set to [FALSE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [bLightOn] to [FALSE] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions


CombLock_Light3Off

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When [CombLock_Selected3] is set to [FALSE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [bLightOn] to [FALSE] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions


CombLock_Light4Off

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When [CombLock_Selected4] is set to [FALSE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [bLightOn] to [FALSE] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions


CombLock_Light1On

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When [CombLock_Selected1] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [bLightOn] to [TRUE] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions


CombLock_Light2On

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When [CombLock_Selected2] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [bLightOn] to [TRUE] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions


CombLock_Light3On

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When [CombLock_Selected3] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [bLightOn] to [TRUE] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions


CombLock_Light4On

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When [CombLock_Selected4] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [bLightOn] to [TRUE] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions


Thank the Builder for the Copy Script button! Minimize the Trigger Script Manager and select the first indicator light. Give it the property Scripts -> TriggerScripts. You will notice that it already has two scripts: TurnOffElecLight and TurnOnElecLight. We don’t want these – they cause the lights to behave oddly (or at least not the way we want them to). Change TurnOffElecLight to CombLock_Light1Off (Click on TurnOffElecLight, click the three dots next to it, browse toCombLock_Light1Off, minimize trigger scripts, click Use). Change TurnOnElecLight to CombLock_Light1On in the same way.

Do the same thing for the other three lights, giving the second light the two CombLock_Light2 scripts, the third light the CombLock_Light3 scripts, and the fourth light the CombLock_Light4 scripts. Close the Trigger Script Manager, Build All, save, etc and go playtest your map. The indicator lights should now work – when you frob one of the RectangleButtons, the indicator light above it should turn on. If it doesn’t work… I must have forgotten something, and it will work by the end of this tutorial!


The Indicators

This is the part that takes a long time (groan). We will now set up the four DiamondButtonMovers (I’ll refer to them as indicators) so that the currently selected one will change to the shape of whichever button you press. We won’t actually ‘tell’ the lock what the correct combination is yet; more on that later.

First create four more flags, CombLock_Correct1, CombLock_Correct2, CombLock_Correct3 and CombLock_Correct4.

Trigger Scripts

Now open the Trigger Script Manager and create a new group under CombinationLock, called DiamondButton. In it create the following four scripts:


CombLock_Diamond1

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected1] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_diamond] on linked objects of [TriggerScript:Indicator1]
Image:action_icon.png Set flag [CombLock_Correct1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Diamond2

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected2] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_diamond] on linked objects of [TriggerScript:Indicator2]
Image:action_icon.png Set flag [CombLock_Correct2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Diamond3

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected3] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_diamond] on linked objects of [TriggerScript:Indicator3]
Image:action_icon.png Set flag [CombLock_Correct3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Diamond4

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected4] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_diamond] on linked objects of [TriggerScript:Indicator4]
Image:action_icon.png Set flag [CombLock_Correct4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


Now give the DiamondButton the property Scripts -> TriggerScripts and add these four new scripts. Go back to the Trigger Script Manager. Create a new group under CombinationLock called SquareButton. In it make the following scripts:

CombLock_Square1

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected1] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_square] on linked objects of [TriggerScript:Indicator1]
Image:action_icon.png Set flag [CombLock_Correct1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Square2

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected2] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_square] on linked objects of [TriggerScript:Indicator2]
Image:action_icon.png Set flag [CombLock_Correct2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Square3

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected3] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_square] on linked objects of [TriggerScript:Indicator3]
Image:action_icon.png Set flag [CombLock_Correct3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Square4

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected4] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_square] on linked objects of [TriggerScript:Indicator4]
Image:action_icon.png Set flag [CombLock_Correct4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


Give these four scripts to your square button. Now create another new group under CombinationLock called CircleButton. In it create these scripts:


CombLock_Circle1

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected1] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_round] on linked objects of [TriggerScript:Indicator1]
Image:action_icon.png Set flag [CombLock_Correct1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Circle2

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected2] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_round] on linked objects of [TriggerScript:Indicator2]
Image:action_icon.png Set flag [CombLock_Correct2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Circle3

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected3] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_round] on linked objects of [TriggerScript:Indicator3]
Image:action_icon.png Set flag [CombLock_Correct3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Circle4

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected4] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_round] on linked objects of [TriggerScript:Indicator4]
Image:action_icon.png Set flag [CombLock_Correct4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


Give these four scripts to your round button. Create a new group under CombinationLock called TriangleButton. In this create these scripts:


CombLock_Triangle1

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected1] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_triangle] on linked objects of [TriggerScript:Indicator1]
Image:action_icon.png Set flag [CombLock_Correct1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Triangle2

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected2] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_triangle] on linked objects of [TriggerScript:Indicator2]
Image:action_icon.png Set flag [CombLock_Correct2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Triangle3

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected3] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_triangle] on linked objects of [TriggerScript:Indicator3]
Image:action_icon.png Set flag [CombLock_Correct3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


CombLock_Triangle4

CombLock_Triangle4

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Selected4] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [ObjectMesh.Name] to [BUTTON_triangle] on linked objects of [TriggerScript:Indicator4]
Image:action_icon.png Set flag [CombLock_Correct4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Image:action_icon.png Reset script conditions and actions


Give these four scripts to your triangle button. That’s all the scripts for now (thank the Builder!), so this would be a good point to save.

Linking

However, these scripts will not work on their own; we need to link together some things.

Note down the names of your four indicators (the names can be found in the title bar of the right click -> properties dialog box). Note them down in the correct order (that is, far left, middle left, middle right, far right) because it is very important we link to the correct ones.

After doing that open up the links of your DiamondButton (right click -> Actor Links) and add a new link. Scroll down the list of links and select TriggerScript, and type the name of the indicator on the far left into the TO box (the name will be in the form DiamondButtonMover__Something (notice there are two underscores)). Click OK. Now click on the TriggerScript link you just created and click the ‘Edit Selected Link’ button. You will now see a window that looks very similar to the actor properties window. Expand the bottom ‘Properties’ line, then expand ‘Link’. In the box to the right of the property m_name type Indicator1. Now expand the TriggerLink line and type Indicator1 in the box next to LinkName. Now click Done. Typing Indicator1 into those two boxes has given that link the name Indicator1.

Now create a TriggerScript link to the second DiamondButtonMover (middle left) and name it Indicator2 in the same way. Create a TriggerScript link to the third DiamondButtonMover (middle right) and name it Indicator3. Create a TriggerScript link to the fourth DiamondButtonMover (far right) and name it Indicator4. Now click Done to close the Links dialog box.

That wasn’t too bad, but unfortunately we have to do the same thing for the other three buttons.

Open the links of your SquareButton. Create a TriggerScript link to the first DiamondButtonMover (far left) and name it Indicator1. Create a TriggerScript link to the second DiamondButtonMover (middle left) and name it Indicator2. Create a TriggerScript link to the third DiamondButtonMover (middle right) and name it Indicator3. Create a TriggerScript link to the fourth DiamondButtonMover (far right) and name it Indicator4. Close the Links dialog box.

Open the links of your RoundButton. Create a TriggerScript link to the first DiamondButtonMover (far left) and name it Indicator1. Create a TriggerScript link to the second DiamondButtonMover (middle left) and name it Indicator2. Create a TriggerScript link to the third DiamondButtonMover (middle right) and name it Indicator3. Create a TriggerScript link to the fourth DiamondButtonMover (far right) and name it Indicator4. Close the Links dialog box.

Open the links of your TriangleButton. Create a TriggerScript link to the first DiamondButtonMover (far left) and name it Indicator1. Create a TriggerScript link to the second DiamondButtonMover (middle left) and name it Indicator2. Create a TriggerScript link to the third DiamondButtonMover (middle right) and name it Indicator3. Create a TriggerScript link to the fourth DiamondButtonMover (far right) and name it Indicator4. Close the Links dialog box.

This would be a good time to save / build all and playtest your map. Now, when you frob one of the four shaped buttons, the indicator above whichever indicator light is currently on should change shape to that of the button you pressed. You’ll be glad to know that the most boring / repetitive part of this tutorial is now over!


The Switch

The switch is how you open the door! When you frob the switch, it checks to see if each of the four indicators is set to the correct shape, and if they all are, it opens the door. Why have a switch and not just have the door open as soon as you enter the correct combination? Two reasons – one, because this lock has less possible combinations than the ones in T2 which use all ten numbers, you are more likely to guess the correct combination; having a switch that you must frob every time would make people less likely to try guessing and make them pay more attention to the clues the FM author gives them. Two, I couldn’t think of a convenient way to make it work without the switch.

Time for the final seven Trigger Scripts!

Open the Trigger Script Manager and create a new group under CombinationLock called Switch. In it create the following scripts:


CombLock_CorrectRedLight

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png Received trigger message [CombinationCorrect]

Image:action_icon.png ACTIONS

Image:action_icon.png Toggle [bLightOn] on linked objects of type [Reference]


CombLock_SwitchCorrect

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Correct1] is set to [TRUE]
Image:Condition_icon.png Query if flag [CombLock_Correct2] is set to [TRUE]
Image:Condition_icon.png Query if flag [CombLock_Correct3] is set to [TRUE]
Image:Condition_icon.png Query if flag [CombLock_Correct4] is set to [TRUE]

Image:action_icon.png ACTIONS

Image:action_icon.png Send trigger message [CombinationCorrect]
Image:action_icon.png Set [HighlightDist] to [0] on linked objects of [MYSELF]
Image:action_icon.png Play sound schema [museum_power_on] in 2D sound
Image:action_icon.png Delay [4.00] GAME seconds
Image:action_icon.png Open any doors on linked object(s) [TriggerScript]


You’ll notice that these scripts don’t have a ‘Reset script conditions and actions’. This is because they will only be fired once, when the door opens.


CombLock_SwitchIncorrect1

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Correct1] is set to [FALSE]

Image:action_icon.png ACTIONS

Image:action_icon.png Send trigger message [CombinationIncorrect]
Image:action_icon.png Reset script conditions and actions


CombLock_SwitchIncorrect2

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Correct2] is set to [FALSE]

Image:action_icon.png ACTIONS

Image:action_icon.png Send trigger message [CombinationIncorrect]
Image:action_icon.png Reset script conditions and actions


CombLock_SwitchIncorrect3

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Correct3] is set to [FALSE]

Image:action_icon.png ACTIONS

Image:action_icon.png Send trigger message [CombinationIncorrect]
Image:action_icon.png Reset script conditions and actions


CombLock_SwitchIncorrect4

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am frobbed by player
Image:Condition_icon.png Query if flag [CombLock_Correct4] is set to [FALSE]

Image:action_icon.png ACTIONS

Image:action_icon.png Send trigger message [CombinationIncorrect]
Image:action_icon.png Reset script conditions and actions


CombLock_SwitchIncorrectResponse

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png Received trigger message [CombinationIncorrect]

Image:action_icon.png ACTIONS

Image:action_icon.png Set [HighlightDist] to [0] on linked objects of [MYSELF]
Image:action_icon.png Play sound schema [museum_power_off] in 2D sound
Image:action_icon.png Delay [3.00] GAME seconds
Image:action_icon.png Close any doors on linked object(s) [MYSELF]
Image:action_icon.png Set [HighlightDist] to [128] on linked objects of [MYSELF]
Image:action_icon.png Reset script conditions and actions

Give these seven scripts to your switch. Now note down the names of your door, your ElecSteamLightbulbRed and your ElecSteamLightbulbGreen (the concretes, not the archetypes). Open your switch’s Links and create a TriggerScript link to your door. Then create a Reference link to your ElecSteamLightbulbRed, and a Reference link to your ElecSteamLightbulbGreen. Close the Links dialog box.

That’s the mechanism of the lock completely set up – when you type the correct combination and frob the switch, the door will open. However, if you playtest your map now, you will notice that no matter what combination you enter, the door will not open. That is because we haven’t yet ‘told’ it what the correct combination is.


Setting the Combination

Now that everything is set up, setting the combination is incredibly simple (and thankfully involves no new scripts!) If you take a closer look at the scripts we created in Part 4a, you will notice that they all set the flags CombLock_Correct1, CombLock_Correct2, CombLock_Correct3 and CombLock_Correct4 to false. These are the flags that are checked by the switch to see whether the door is opened or not. To set the combination, we simply need to modify four of the scripts so that pressing the correct shape for that indicator sets the flag to true. But which scripts?

Lets say we want the correct combination to be (from the left) triangle, circle, square, circle. So we want the 1st indicator to be a triangle – we need to modify the script that has a 1and Trianglein its name: CombLock_Triangle1. Find this script in the Trigger Script Manager, select it, and click Edit. On the action Image:action_icon.png Set flag [CombLock_Correct1] to [FALSE] expires on map change [FALSE] expires on mission [-1] change the first FALSE to TRUE.

We want the 2nd indicator to be a circle, so edit the script CombLock_Circle2, and in the action Image:action_icon.png Set flag [CombLock_Correct2] to [FALSE] expires on map change [FALSE] expires on mission [-1] change the first FALSE to TRUE.

We want the 3rd indicator to be a square, so edit the script CombLock_Square3, and in the action Image:action_icon.png Set flag [CombLock_Correct3] to [FALSE] expires on map change [FALSE] expires on mission [-1] change the first FALSE to TRUE.

We want the 4th indicator to be a circle, so edit the script CombLock_Circle4, and in the action Image:action_icon.png Set flag [CombLock_Correct4] to [FALSE] expires on map change [FALSE] expires on mission [-1] change the first FALSE to TRUE.

Save the scripts, build all, save your map, and playtest it. You should now find that if you enter the combination triangle circle square circle and frob the switch, the light will turn green and the door will open!

Setting your own combination is just as simple – just match up the indicator number and the shape you want it, this will tell you which script to edit. (Don’t forget to set the scripts for this tutorial’s combination to FALSE before you do so)

And that’s it. You now have a working combination lock!


TTLG Forum Discussion



Back to Doors, Locks and Keys Tutorials Page

Back to Mission Design: World Objects Tutorials Page

Back to Mission Design Tutorials Page

Back to Main Tutorials Page

Personal tools