A clock chimes every hour

Hello, everyone. Sorry if this question is dull or somebody asked the same before but I can´t find the exact thing I am searching.

I want to include a message telling the player the O´clock hour every time the cathedral´s bells are ringing, but I don´t know how to do this without giving an instruction for each hour.

Thank you!

Every turn:
	If the minutes part of time of day is 0:
		say "The cathedral bells chime [hours part of time of day] o'clock."

EDIT: To avoid odd announcements like ‘The cathedral bells chime 13 o’clock’ if your game stretches into the afternoon and evening, one of these these modifications might be advisable:

Every turn:
	If the minutes part of time of day is 0:
		say "The cathedral bells chime [if hours part of time of day is greater than 12][hours part of time of day minus 12][otherwise][hours part of time of day][end if] o'clock."

or

Every turn:
	If the minutes part of time of day is 0:
		say "The cathedral bells chime [hours part of time of day] times, signalling [if hours part of time of day is greater than 12][hours part of time of day minus 12][otherwise][hours part of time of day][end if] o'clock."
4 Likes

Thank you very much!

This solution is definitely great. Just be aware if you do any tricky stuff with the time like skipping forward the chime message won’t happen. That might be correct - if the character sleeps or flashes forward in time they shouldn’t hear it.

Be mindful than any important plot or scene-change mechanics that occur based on the clock require special care if the player or the game can adjust or reset the game clock in any way. For example if a sunrise backdrop is scheduled to appear at 6:00 AM and you allow the player to sleep through that by cranking the clock forward it will throw things out of whack - if “6 AM doesn’t happen” your sun won’t rise!

3 Likes

Thank you for your insights. Indeed, the solution from Dr Peter Bate worked as charm as far as I have advanced in my game.
Understood. So I have to be careful because there are some situations when the player faint. I suppose I could skip detailed descriptions about what´s going on with the sun or the moon. In fact, the scenery of the city is very grey and gloomy, so hopefully it would not be a problem(?)

If you are skipping time forward while the player is fainted, but want the bells to appear to wake the player, you’d need to make sure you skip time forward to the next (or at least some) o’clock (assuming they are unconscious long enough to reach the next o’clock).

Otherwise, if the bells don’t wake the player it doesn’t matter that they won’t hear the chime message while unconscious.

2 Likes

It might be a slight problem if you’re telling the player it’s midnight but it hasn’t gone dark! Unless your game is set at midsummer within the Arctic or Antarctic circles, when the sun doesn’t set…

1 Like

I see. My game is not very realistic and has a dreamy-nighmarish atmosphere, but the bells waking up the player it´s a nice detail I´ll have in mind. Very grateful for the idea.

Is there any trick to circumvent the problem with the sun losing its ticket to sunrise/sunrise? :smile:
(Although maybe the code to do it is too complex for a novice like me). In any case, just knowing the problems I can encounter,I´ll be wary with my descriptions.

You just need to make sure that the sun isn’t set to rise or set at a specific time that you skip past.

If you have a rule for example:

daylight is a truth state that varies.
Every turn:
	if time of day is 06:00 AM:
		say "The sun has risen, seeping a grey light into the foggy streets...";
		now daylight is true.

daylight will never come if the time of day skips past 06:00 AM.

However…

daylight is a truth state that varies.
Every turn:
	if time of day is after 05:59 AM and daylight is false:
		say "The sun has risen, seeping a grey light into the foggy streets...";
		now daylight is true.

daylight will come at the first turn after 05:59 AM.

Obviously, you could make a similar rule for sunset, and as a bit of syntactic sugar, also create a phrase to determine day and night that can be easily incorporated into descriptions:

To decide whether daytime:
	if time of day is after 05:59 AM and time of day is before 08:00 PM , yes;
	no.

daylight is a truth state that varies.	
Every turn:
	if daytime and daylight is false:
		say "The sun has risen, seeping a grey light into the foggy streets...";
		now daylight is true;
	if not daytime and daylight is true:
		say "The sun has set, darkening the foggy streets...";
		now daylight is false.

example description

"[if daytime]An unlit street lamp stands black and pencil-like amidst the swirling mists.[otherwise]The soft glow of a street lamp struggles to penetrate the swirling mists.".
2 Likes

A fascinating solution. I am still familiarizing with Inform 7 and its logic, but this is great. I love adventure games with dynamic environments and this would help a lot with the atmosphere. By the way, I loved your street lamp description.

1 Like