Zh/Clock

本教程将展示如何创建在的第一个实验室中看到的时钟。时钟用于显示距离第一个房间中的传送门打开还剩多少时间。
__NOTOC__
==创建==
===第一步===
创建一个实体，并将模型设定为models/props/clock.mdl，将其Pitch Yaw Roll改为-90 180 0并将禁用阴影设置为yes。
===第二步===
创建一个对齐最左边的2w*10l*10h笔刷aligned to the left within the clock model. Texture the front side with signage/clock/clock_minutes and press "Fit" to fit the texture on the brush. Tie this brush to a entity and set its Name to brush_clock_minutes.
Next create a 2w*2l*10h brush right next to the previous brush. Texture the front with signage/clock/clock_dots and fit the texture to the brush. Tie this brush to a entity.
After that, create another 2w*10l*10h brush next to the previous brush and texture the front with signage/clock/clock_seconds and fit the texture to the brush. Tie this brush to a func_brush entity and set its Name to brush_clock_seconds.
Create another 2w*2l*10h brush with the front textured with signage/clock/clock_dots and tie it to a func_detail.
Now create another 2w*10l*10h brush and texture the front with signage/clock/clock_centiseconds. Tie it to a func_brush and set its Name to brush_clock_centiseconds.
Next create another 2w*2l*10h func_detail brush with the front textured with signage/clock/clock_dots.
Finally, create another 2w*10l*10h with the front textured with signage/clock/clock_milliseconds. Tie it to a func_brush and set its Name to brush_clock_milliseconds.
File:Clock_brush_minutes.png|The minutes display brush
File:Clock_brush_dots1.png|The first "dots" display brush
File:Clock_brush_seconds.png|The seconds display brush
File:Clock_brush_dots2.png|The second "dots" display brush
File:Clock_brush_centiseconds.png|The centiseconds display brush
File:Clock_brush_dots3.png|The third "dots" display brush
File:Clock_brush_milliseconds.png|The milliseconds display brush
=== Step 3 ===
Create an entity. Set its Name to texturetoggle_clock_minutes and set its Target Brush(es) to brush_clock_minutes.
Next create another env_texturetoggle and set its Name to texturetoggle_clock_seconds and set its Target Brush(es) to brush_clock_seconds.
After that, create a entity. Set its Name to mmc_clock_centiseconds, set its Parent to brush_clock_centiseconds, set its Material to modify. to signage/clock/clock_centiseconds, and set its Material variable to modify to $frame.
Finally, create another material_modify_control entity and set its Name to mmc_clock_milliseconds, set its Parent to brush_clock_milliseconds, set its Material to modify. to signage/clock/clock_milliseconds, and set its Material variable to modify to $frame.
File:Clock_texturetoggle_minutes.png|The texturetoggle_clock_minutes entity
File:Clock_texturetoggle_seconds.png|The texturetoggle_clock_seconds entity
File:Clock_mmc_centiseconds.png|The mmc_clock_centiseconds entity
File:Clock_mmc_milliseconds.png|The mmc_clock_milliseconds entity
=== Step 4 ===
Create a entity. Set its Name to timer_clock_minutes, set Start Disabled to Yes and set its Refire Interval to 1. Next, give it the following outputs:
	OnTimer	texturetoggle_clock_minutes	IncrementTextureIndex	 	0.00	No
	OnTimer	timer_clock_minutes 	Disable 	 	0.10	No
Next, create another logic_timer entity and set its Name to timer_clock_seconds, set Start Disabled to Yes, and set its Refire Interval to 1. Add the following outputs to it:
	OnTimer	texturetoggle_clock_seconds	IncrementTextureIndex	 	0.00	No
	OnTimer	counter_clock 	Add 	1 	0.00	No
	OnTimer	counter_clock_2 	Add 	1 	0.00	No
After that, create another logic_timer entity. Set its Name to timer_clock_centiseconds, set Start Disabled to Yes, set its Refire Interval to 1, and add the following output to it:
	OnTimer	mmc_clock_centiseconds	StartFloatLerp	0 59 1 0	0.00	No
Finally, create another logic_timer entity and set its Name to timer_clock_milliseconds, set Start Disabled to Yes, and set its Refire Interval to .1. Add the following output to it:
	OnTimer	mmc_clock_milliseconds	StartFloatLerp	0 9 .1 1	0.00	No
File:Clock_timer_minutes.png|The timer_clock_minutes entity
File:Clock_timer_seconds.png|The timer_clock_seconds entity
File:Clock_timer_centiseconds.png|The timer_clock_centiseconds entity
File:Clock_timer_milliseconds.png|The timer_clock_milliseconds entity
=== Step 5 ===
Create a entity. Set its Name to counter_clock, set its Maximum Legal Value to 60, and add the following outputs:
	OnHitMax	timer_clock_seconds 	Disable 	 	0.00	No
	OnHitMax	texturetoggle_clock_seconds	SetTextureIndex	59 	0.00	No
	OnHitMax	timer_ticktock1 	Disable 	 	0.00	No
Next, create another math_counter and set its Name to counter_clock_2 and set its Maximum Legal Value to 59. Now add the following outputs to it:
	OnHitMax	timer_clock_centiseconds	Disable	 	0.00	No
	OnHitMax	timer_clock_milliseconds	Disable	 	1.00	No
=== Step 6 ===
Create a entity. Set its Name to sound_ticktock1, set its Sound Name to Portal.room1_TickTock, set its Volume to 5 and set its Max Audible Distance to 441.
Next, create a logic_timer entity, set its Name to timer_ticktock1, set Start Disabled to Yes, set its Refire Interval to 1 and add the following output to it:
	OnTimer	sound_ticktock1	PlaySound	 	0.00	No
=== Step 7 ===
Create a entity and add the following outputs to it:
	OnMapSpawn	mmc_clock_milliseconds 	SetMaterialVar 	9 	0.00	No
	OnMapSpawn	mmc_clock_centiseconds 	SetMaterialVar 	59	0.00	No
	OnMapSpawn	texturetoggle_clock_seconds	SetTextureIndex	59	0.00	No
=== Step 8 ===
Create a and set its Name to relay_start_clock. Add the following outputs to it:
	OnTrigger	timer_clock_minutes 	Enable	 	0.00	No
	OnTrigger	timer_clock_seconds 	Enable	 	0.00	No
	OnTrigger	timer_clock_centiseconds	Enable	 	0.00	No
	OnTrigger	timer_ticktock1 	Enable	 	0.00	No
	OnTrigger	timer_clock_milliseconds	Enable	 	0.90	No
The clock is now finished and ready to be implemented in a map.
== Implementation ==
=== Step 1 ===
Position the clock on the wall where it should be in the map.
=== Step 2 ===
Send the Trigger input to the relay_start_clock relay when the countdown should begin.
Category:Portal
Category:Level Design
Category:Tutorials