<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.thedarkmod.com/index.php?action=history&amp;feed=atom&amp;title=Clocks_With_Chimes</id>
	<title>Clocks With Chimes - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.thedarkmod.com/index.php?action=history&amp;feed=atom&amp;title=Clocks_With_Chimes"/>
	<link rel="alternate" type="text/html" href="https://wiki.thedarkmod.com/index.php?title=Clocks_With_Chimes&amp;action=history"/>
	<updated>2026-05-03T10:22:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://wiki.thedarkmod.com/index.php?title=Clocks_With_Chimes&amp;diff=20694&amp;oldid=prev</id>
		<title>Grayman: Created page with &quot;&#039;&#039;Written by grayman, who started with a set of instructions for a non-chiming clock, written by Fidcal.&#039;&#039;    == Introduction ==  &#039;&#039;&#039;SUMMARY: A TDM 2.07+ script and clock setu...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.thedarkmod.com/index.php?title=Clocks_With_Chimes&amp;diff=20694&amp;oldid=prev"/>
		<updated>2018-10-16T19:17:36Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;Written by grayman, who started with a set of instructions for a non-chiming clock, written by Fidcal.&amp;#039;&amp;#039;    == Introduction ==  &amp;#039;&amp;#039;&amp;#039;SUMMARY: A TDM 2.07+ script and clock setu...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;Written by grayman, who started with a set of instructions for a non-chiming clock, written by Fidcal.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;SUMMARY: A TDM 2.07+ script and clock setup that lets the clock chime on the quarter-hour and hour.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
This assumes that the clock&amp;#039;s hand movement is managed by the materials for the big and little hands.&lt;br /&gt;
&lt;br /&gt;
==The Clock==&lt;br /&gt;
A prefab grandfather clock with chime support is provided in prefabs/furniture/misc/grandfather_clock.pfb.&lt;br /&gt;
Place one in your map and look how it&amp;#039;s set up.&lt;br /&gt;
By default, this clock is set to 2:00, which is where the hands will point at mission start. If you want to change the starting time, set these spawnargs:&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;shaderparm7 H&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;shaderparm8 M&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
H = The hour&lt;br /&gt;
&lt;br /&gt;
M = The minute&lt;br /&gt;
&lt;br /&gt;
If you set M to anything but 0, you&amp;#039;ll need to set H accordingly. For example, here are settings for starting at 2:15 ...&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;shaderparm7 2.25&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;shaderparm8 15&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==The Clock Scripts==&lt;br /&gt;
&lt;br /&gt;
This is the script that keeps time and rotates the clock hands. See next section for how to set it up...&lt;br /&gt;
&lt;br /&gt;
  // ------------------------------- HOUSE TIME - CLOCK CHIMES --------------------------------------&lt;br /&gt;
  &lt;br /&gt;
  #define START_HR	       2&lt;br /&gt;
  #define START_MIN	       0&lt;br /&gt;
  #define TIME_INTERVAL        15&lt;br /&gt;
  #define CHIME_PAUSE         1.9&lt;br /&gt;
  &lt;br /&gt;
  // Each clock targets speakers that handle the chimes.&lt;br /&gt;
  //&lt;br /&gt;
  // target0 is one of the speakers that handles the hour chime.&lt;br /&gt;
  // target1 is one of the speakers that handles the hour chime.&lt;br /&gt;
  // target2 is one of the speakers that handles the hour chime.&lt;br /&gt;
  // target3 is the speaker that handles the 15-min chime.&lt;br /&gt;
  // target4 is the speaker that handles the 30-min chime.&lt;br /&gt;
  // target5 is the speaker that handles the 45-min chime.&lt;br /&gt;
  // target6 is the speaker that handles the 60-min chime.&lt;br /&gt;
  &lt;br /&gt;
  void ChimeMinutes( entity clock, float minutes )&lt;br /&gt;
  {&lt;br /&gt;
  	entity speaker;&lt;br /&gt;
  	if ( minutes == TIME_INTERVAL )&lt;br /&gt;
  	{&lt;br /&gt;
  		speaker = clock.getTarget(3);&lt;br /&gt;
  	}&lt;br /&gt;
  	else if ( minutes == 2*TIME_INTERVAL )&lt;br /&gt;
  	{&lt;br /&gt;
  		speaker = clock.getTarget(4);&lt;br /&gt;
  	}&lt;br /&gt;
  	else // 3*TIME_INTERVAL&lt;br /&gt;
  	{&lt;br /&gt;
  		speaker = clock.getTarget(5);&lt;br /&gt;
  	}&lt;br /&gt;
  	speaker.activate($player1);&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // Each clock targets three speakers that handle the individual&lt;br /&gt;
  // hour chimes. Having three rather than one allows us to&lt;br /&gt;
  // overlap the chimes. Three is the minimum number needed to&lt;br /&gt;
  // achieve a nice sequence of overlapped chimes.&lt;br /&gt;
  //&lt;br /&gt;
  // target6 is the speaker that handles the pre-chime sound.&lt;br /&gt;
  // target{0,1,2} are the speakers that handle the hour chimes.&lt;br /&gt;
  &lt;br /&gt;
  void ChimeHour( entity clock, float hour)&lt;br /&gt;
  {&lt;br /&gt;
  	clock.getTarget(6).activate($player1);&lt;br /&gt;
  	sys.wait(14.5); // let this chime nearly complete. there&amp;#039;s a little blend in the last second or so.&lt;br /&gt;
  &lt;br /&gt;
  	entity speaker1 = clock.getTarget(0);&lt;br /&gt;
  &lt;br /&gt;
  	speaker1.activate($player1);&lt;br /&gt;
  	if ( hour &amp;gt; 1 )&lt;br /&gt;
  	{&lt;br /&gt;
  		sys.wait(CHIME_PAUSE);&lt;br /&gt;
  		entity speaker2 = clock.getTarget(1);&lt;br /&gt;
  		speaker2.activate($player1);&lt;br /&gt;
  		if ( hour &amp;gt; 2 )&lt;br /&gt;
  		{&lt;br /&gt;
  			sys.wait(CHIME_PAUSE);&lt;br /&gt;
  			entity speaker3 = clock.getTarget(2);&lt;br /&gt;
  			speaker3.activate($player1);&lt;br /&gt;
  			if ( hour &amp;gt; 3 )&lt;br /&gt;
  			{&lt;br /&gt;
  				sys.wait(CHIME_PAUSE);&lt;br /&gt;
  				speaker1.activate($player1);&lt;br /&gt;
  				if ( hour &amp;gt; 4 )&lt;br /&gt;
  				{&lt;br /&gt;
  					sys.wait(CHIME_PAUSE);&lt;br /&gt;
  					speaker2.activate($player1);&lt;br /&gt;
  					if ( hour &amp;gt; 5 )&lt;br /&gt;
  					{&lt;br /&gt;
  						sys.wait(CHIME_PAUSE);&lt;br /&gt;
  						speaker3.activate($player1);&lt;br /&gt;
  						if ( hour &amp;gt; 6 )&lt;br /&gt;
  						{&lt;br /&gt;
  							sys.wait(CHIME_PAUSE);&lt;br /&gt;
  							speaker1.activate($player1);&lt;br /&gt;
  							if ( hour &amp;gt; 7 )&lt;br /&gt;
  							{&lt;br /&gt;
  								sys.wait(CHIME_PAUSE);&lt;br /&gt;
  								speaker2.activate($player1);&lt;br /&gt;
  								if ( hour &amp;gt; 8 )&lt;br /&gt;
  								{&lt;br /&gt;
  									sys.wait(CHIME_PAUSE);&lt;br /&gt;
  									speaker3.activate($player1);&lt;br /&gt;
  									if ( hour &amp;gt; 9 )&lt;br /&gt;
  									{&lt;br /&gt;
  										sys.wait(CHIME_PAUSE);&lt;br /&gt;
  										speaker1.activate($player1);&lt;br /&gt;
  										if ( hour &amp;gt; 10 )&lt;br /&gt;
  										{&lt;br /&gt;
  											sys.wait(CHIME_PAUSE);&lt;br /&gt;
  											speaker2.activate($player1);&lt;br /&gt;
  											if ( hour &amp;gt; 11 )&lt;br /&gt;
  											{&lt;br /&gt;
  												sys.wait(CHIME_PAUSE);&lt;br /&gt;
  												speaker3.activate($player1);&lt;br /&gt;
  											}&lt;br /&gt;
  										}&lt;br /&gt;
  									}&lt;br /&gt;
  								}&lt;br /&gt;
  							}&lt;br /&gt;
  						}&lt;br /&gt;
  					}&lt;br /&gt;
  				}&lt;br /&gt;
  			}&lt;br /&gt;
  		}&lt;br /&gt;
  	}&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  // HouseTime()&lt;br /&gt;
  //&lt;br /&gt;
  // - chimes the clocks every TIME_INTERVAL minutes&lt;br /&gt;
  // - chimes the clocks at the top of each hour, one chime for each hour&lt;br /&gt;
  &lt;br /&gt;
  void HouseTime()&lt;br /&gt;
  {&lt;br /&gt;
  	float timeHr  = START_HR;&lt;br /&gt;
  	float timeMin = START_MIN;&lt;br /&gt;
  &lt;br /&gt;
  	while ( 1 )&lt;br /&gt;
  	{&lt;br /&gt;
  		if ( timeMin != 4*TIME_INTERVAL )&lt;br /&gt;
  		{&lt;br /&gt;
  			// play minutes chime at each clock&lt;br /&gt;
  &lt;br /&gt;
  			thread ChimeMinutes( $Clock1, timeMin );&lt;br /&gt;
  			//thread ChimeMinutes( $Clock2, timeMin );&lt;br /&gt;
  		}&lt;br /&gt;
  		else&lt;br /&gt;
  		{&lt;br /&gt;
  			timeMin = 0; // top of the hour&lt;br /&gt;
  			timeHr = timeHr + 1;&lt;br /&gt;
  			if ( timeHr == 13 )&lt;br /&gt;
  			{&lt;br /&gt;
  				timeHr = 1;&lt;br /&gt;
  			}&lt;br /&gt;
  &lt;br /&gt;
  			// play hour chime at each clock&lt;br /&gt;
  &lt;br /&gt;
  			thread ChimeHour( $Clock1, timeHr );&lt;br /&gt;
  			//thread ChimeHour( $Clock2, timeHr );&lt;br /&gt;
  		}&lt;br /&gt;
  &lt;br /&gt;
  		sys.wait(TIME_INTERVAL*60); // sleep for TIME_INTERVAL minutes&lt;br /&gt;
  		timeMin = timeMin + TIME_INTERVAL;&lt;br /&gt;
  	}&lt;br /&gt;
  }  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== How to Set Up the Scripts &amp;amp; Clock ==&lt;br /&gt;
&lt;br /&gt;
The clock scripts are listed in the previous section. This is how you set them up...&lt;br /&gt;
&lt;br /&gt;
* Copy the &amp;#039;&amp;#039;ChimeMinutes(), ChimeHour()&amp;#039;&amp;#039; and &amp;#039;&amp;#039;HouseTime()&amp;#039;&amp;#039; scripts from above.&lt;br /&gt;
* If you already have a script file for your map then paste these scripts into it (above the &amp;#039;&amp;#039;main()&amp;#039;&amp;#039; routine), or....&lt;br /&gt;
* If you haven&amp;#039;t already got a script file then paste the clock scripts into your plain text editor and save them in the same folder as your map with the same name but suffix .script. Example :&amp;lt;br&amp;gt;mymapname.map&amp;lt;br&amp;gt;mymapname.script. Add a &amp;#039;&amp;#039;main()&amp;#039;&amp;#039; routine.&lt;br /&gt;
* Edit the lines START_HR and START_MIN for the time you want the clock to show at the start.&lt;br /&gt;
* Resave the file.&lt;br /&gt;
* Import one of the clock prefabs.&lt;br /&gt;
* Make sure the clock entity is named &amp;quot;Clock1&amp;quot;.&lt;br /&gt;
* Position and turn the entire clock prefab to face the way you want it in-game.&lt;br /&gt;
* The clock is now ready to keep and show time in your Dark Mod mission.&lt;br /&gt;
* If you want another clock, import another prefab clock and place it where you want. DR should name it &amp;quot;Clock2&amp;quot;. Look for the lines in the scripts that reference &amp;quot;Clock2&amp;quot; and uncomment them (Delete the &amp;#039;&amp;#039;//&amp;#039;&amp;#039; at the start of the line). If you add a third clock, add lines for &amp;quot;Clock3&amp;quot; beneath the lines that reference &amp;quot;Clock2&amp;quot;. Further clocks can be added the same way.&lt;br /&gt;
&lt;br /&gt;
== Starting the Clock at Mission Start ==&lt;br /&gt;
&lt;br /&gt;
* To start the clock running at the &amp;#039;&amp;#039;start&amp;#039;&amp;#039; of the mission you must also have in your script file this &amp;#039;&amp;#039;main()&amp;#039;&amp;#039; routine (add it if not there) and insert a line between its curly brackets as shown. The &amp;#039;&amp;#039;main()&amp;#039;&amp;#039; routine must be placed BELOW the &amp;#039;&amp;#039;HouseTime()&amp;#039;&amp;#039; script routine:&lt;br /&gt;
&lt;br /&gt;
  void main ()&lt;br /&gt;
  {&lt;br /&gt;
  	thread HouseTime();&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
* The &amp;#039;&amp;#039;main()&amp;#039;&amp;#039; routine will run automatically at mission start and the clock will begin working.&lt;br /&gt;
&lt;br /&gt;
[[Category:Editing]]&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Grayman</name></author>
	</entry>
</feed>