Portal Clock Timer

Tutorial collection, comprehensive listings on main site.

Portal Clock Timer

Postby Tutorial on Sun Aug 31, 2008 11:43 am

category
Portal

description
Creating a clock timer that counts down from 01:00:00:00, like the one seen in your cell in the beginning of the game.

keywords
portal, clock, timer, countdown, count, down.

After mucking around with logic_timers and env_texturetoggles for hours, I was finally able to figure out how to make this clock work, and boy is it a pain. This intermediate level tutorial will show anyone how to get it working, hopefully in less time than it took me.

1. Create a room or open up the room you want to put the clock in in hammer. A simple room with a button to trigger the timer will do for this tutorial.

Image

2. First let's build the body of the clock. Create a prop_dynamic, and set the model to props/clock.mdl. Place it on the wall where you want it. Next, create the LCD screen. The screen consists of seven blocks: four 10h x 10w x 2deep blocks separated by three 10h x 2w x 2deep blocks, arranged in a row. Texture the blocks in nodraw.

Image

Next, open up the texture browser and find the clock textures (search "signage"). Apply them to the front faces of the blocks, from left to right, in the following order: clock_minutes, clock_dots, clock_seconds, clock_dots, clock_centiseconds, clock_dots, clock_milliseconds. The texture scale for the numbers is X: .08, Y: .08, and the scale for the dots is X: .10, Y: .10.

Image

Finally, move the LCD screen into place in the clock frame.

3. Now come the entities. There are sixteen (!) of them in total. First, select each of the blocks on the LCD screen bearing numbers and make them into func_brushes (the blocks bearing dots should remain world brushes). With this many entities, you're going to do yourself a huge favor by naming them according to a common naming scheme. I named mine, from left to right: clock_minute_brush, clock_second_brush, clock_centisecond_brush, clock_millisecond_brush.

Image

Next, create the following entities: two env_texturtoggle, two material_modify_control, four logic_timer, two math_counter, one logic_relay, and one logic_auto. Name them according to the scheme:
env_texturtoggle 1: clock_minute_toggle
env_texturtoggle 2: clock_second_toggle
material_modify_control 1: clock_centisecond_mmc
material_modify_control 2: clock_millisecond_mmc
logic_timer 1: clock_minute_timer
logic_timer 2: clock_second_timer
logic_timer 3: clock_centisecond_timer
logic_timer 4: clock_millisecond_timer
math_counter 1: clock_counter
math_counter 2: clock_counter_2
logic_relay: clock_relay
(logic_autos cannot be named)

Arrange them in a visually appealing display. (Not a necessary step.)

Image

4. Now for the fun part. First, open the logic_auto, go to the outputs tab, and create the following outputs:
Image
This sets the clock to 01:00:00:00 when the map starts.

Now open clock_relay. Make sure Start Disabled is set to No or 0, then enter the following outputs:
Image
Once the rest of the IO setup is complete, triggering this logic_relay will start the countdown.

Next, we'll tackle the timers. Set each one up the same way: Start Disabled - yes; Use Random Time - No; Refire Interval - 1. The only odd man out is clock_millisecond_timer, whose Refire Interval should be set to .1. Each timer is linked to its respective env_texturetoggle or material_modify_control:

clock_minute_timer:
Image
This timer shuts itself off after changing 01:xx:xx:xx to 00:xx:xx:xx.

clock_second_timer:
Image
This timer also adds to each of the math_counters, allowing Source to keep track of the timer's progress.

clock_centisecond_timer:
Image
Neither the centisecond nor millisecond panels can be controlled by env_texturetoggle; they must instead be controlled by material_modify_control entities. This had me hung up for a long time when I was trying to build this clock. Each number in the "parameters" column is separated by a space.

clock_millisecond_timer:
Image
The parameters column here reads "0[space]9[space].1[space]1".

Now for the math_counters. These are responsible for halting the countdown when it reaches 00:00:00:00.

clock_counter: set Start Disabled to No and Maximum Legal Value to 60, then enter the following outputs.
Image

clock_counter_2: set Start Disabled to No and Maximum Legal Value to 59, then enter the following outputs.
Image

Finally we come to the env_texturetoggles and material_modify_controls. No IO work is necessary for these, but their settings do need to be adjusted.

clock_minute_toggle: set Target Brush(es) to clock_minute_brush.

clock_second_toggle: set Target Brush(es) to clock_second_brush.

clock_centisecond_mmc: set Parent to clock_centisecond_brush, Material to modify to signage/clock/clock_centiseconds, and Material variable to modify to $frame.

clock_millisecond_mmc: set Parent to clock_millisecond_brush, Material to modify to signage/clock/clock_milliseconds, and Material variable to modify to $frame.

That should be it! To start the countdown, just input "Trigger" to clock_relay. In my example map, I've chosen to do that by means of a button.

Linking Two or More Clocks Together
In portal, these clocks are seen in a pair at the beginning of the game: one over each autoportal frame, inside and outside of your cell, counting down in unison. Unfortunately, achieving this isn't as easy as copy/pasting the "body" of the clock to another part of the map, but it's a sight easier to create the second clock than it is the first clock.

1. Copy/paste the body of the clock to another part of the map (I know what I just said... just keep reading).

2. The env_texturetoggles on the first clock are capable of handling the minutes and seconds on clock #2, but the material_modify_controls on the first clock are not capable of controlling clock #2's centiseconds and milliseconds displays (unless the two clocks are in very near proximity to each other, in which case they sometimes can). To remedy this, select clock_centisecond_brush and clock_millisecond_brush on clock #2 and change their names to clock2_centisecond_brush and clock2_millisecond_brush. Create two more material_modify_controls, and name them clock2_centisecond_mmc and clock2_millisecond_mmc.

clock2_centisecond_mmc: set Parent to clock2_centisecond_brush, Material to modify to signage/clock/clock_centiseconds, and Material variable to modify to $frame.

clock2_millisecond_mmc: set Parent to clock2_millisecond_brush, Material to modify to signage/clock/clock_milliseconds, and Material variable to modify to $frame.

Now go back to clock_centisecond_timer and clock_millisecond_timer and a new output to each.

clock_centisecond_timer:
Image

clock_millisecond_timer:
Image

Done! When clock_relay is triggered, both clocks will count down in unison. I haven't added more than two clocks, but you could conceivably add as many as you want with this method.

~Geekofalltrades
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Re: Portal Clock Timer

Postby iDeekz on Sun Aug 31, 2008 1:15 pm

Very good tutorial. I may use that in future maps.
iDeekz
Regular
Regular
 
Joined: Sun Aug 31, 2008 12:41 am

Re: Portal Clock Timer

Postby TheDoctor on Mon Jan 18, 2010 12:21 pm

Great tutorial, but one of the images for Output parameters is broken? Does anyone have that image?

EDIT: Disregard that message, on closer inspection it's apparent that the url was slightly wrong:

Code: Select all
hhttp://www.interlopers.net/images/hl2tutorials/portal_timer/minutetimergg4.jpg
http://www.interlopers.net/images/hl2tutorials/portal_timer/minutetimergg4.jpg


Image
TheDoctor
Dumpling
Dumpling
 
Joined: Mon Jan 18, 2010 12:18 pm

Re: Portal Clock Timer

Postby XFunc_CaRteR on Tue Feb 21, 2012 6:50 pm

Um... Why don't you just upload the map with this clock. That would save us a ton of work having to build it.

I would appreciate you far more if you did that.
XFunc_CaRteR
Dumpling
Dumpling
 
Joined: Thu Nov 17, 2011 3:23 am

Re: Portal Clock Timer

Postby Dives on Tue Feb 21, 2012 7:57 pm

Because you don't become a better mapper by copying something without fully understanding it. The point of tutorials is to learn.
User avatar
Dives
May Contain Skills
May Contain Skills
 
Joined: Sat Feb 28, 2009 9:54 pm
Location: Moorpark, CA

Re: Portal Clock Timer

Postby Gary on Wed Feb 22, 2012 12:26 am

And thinking about it... a custom VGUI entity would be so much better for this...

Of course that would be out of the question if you can't code.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Return to Tutorials

Who is online

Users browsing this forum: Google [Bot]