Rantako on 14/7/2005 at 15:57
Inline Image:
http://img165.imageshack.us/img165/681/combinationlockpic6gy.jpgThis 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 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.
Part 1: Changes to GamesysFirst we will make all the changes we need to the Gamesys.
LightsCreate 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.
ButtonsFor 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.
Part 2: Building the LockMake 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: 0Place 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: FalsePlace an
ElecSteamLightbulbGreen next to the
ElectSteamLightbulbRed, above the door. Give it the properties:
Lighting -> bLightOn: False
Scripts -> bEnableScriptInherit: FalsePlace 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:
(
http://img344.imageshack.us/my.php?image=comblock2a0re.jpg)
Inline Image:
http://img344.imageshack.us/img344/7334/comblock2a0re.th.jpg(The wiring is simply for decoration)
Part 3: The Indicator LightsWe 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 (! :eek: ) by the end of this tutorial (luckily, a lot of them are very similar, so you can copy them).
Create the following scripts:
CombLock_Selected1Conditions:
When I am frobbed by playerActions:
Set flag [CombLock_Selected1] to [TRUE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Reset script conditions and actionsCombLock_Selected2Conditions:
When I am frobbed by playerActions
Set flag [CombLock_Selected1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected2] to [TRUE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Reset script conditions and actionsCombLock_Selected3Conditions:
When I am frobbed by playerActions
Set flag [CombLock_Selected1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected3] to [TRUE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected4] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Reset script conditions and actionsCombLock_Selected4Conditions:
When I am frobbed by playerActions
Set flag [CombLock_Selected1] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected2] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected3] to [FALSE] expires on map change [FALSE] expires on mission [-1]
Set flag [CombLock_Selected4] to [TRUE] expires on map change [FALSE] expires on mission [-1]
Reset script conditions and actionsMinimize 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_Light1OffConditions:
When [CombLock_Selected1] is set to [FALSE]Actions:
Set [bLightOn] to [FALSE] on linked objects of [MYSELF]
Reset script conditions and actionsCombLock_Light2OffConditions:
When [CombLock_Selected2] is set to [FALSE]Actions:
Set [bLightOn] to [FALSE] on linked objects of [MYSELF]
Reset script conditions and actionsCombLock_Light3OffConditions:
When [CombLock_Selected3] is set to [FALSE]Actions:
Set [bLightOn] to [FALSE] on linked objects of [MYSELF]
Reset script conditions and actionsCombLock_Light4OffConditions:
When [CombLock_Selected4] is set to [FALSE]Actions:
Set [bLightOn] to [FALSE] on linked objects of [MYSELF]
Reset script conditions and actionsCombLock_Light1OnConditions:
When [CombLock_Selected1] is set to [TRUE]Actions:
Set [bLightOn] to [TRUE] on linked objects of [MYSELF]
Reset script conditions and actionsCombLock_Light2OnConditions:
When [CombLock_Selected2] is set to [TRUE]Actions:
Set [bLightOn] to [TRUE] on linked objects of [MYSELF]
Reset script conditions and actionsCombLock_Light3OnConditions:
When [CombLock_Selected3] is set to [TRUE]Actions:
Set [bLightOn] to [TRUE] on linked objects of [MYSELF]
Reset script conditions and actionsCombLock_Light4OnConditions:
When [CombLock_Selected4] is set to [TRUE]Actions:
Set [bLightOn] to [TRUE] on linked objects of [MYSELF]
Reset script conditions and actionsThank 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!