[help] Time of day and day/night cycling

Hi, I want to create an ‘‘open world’’ kind of game with cities. So I want to make a day night cycle, so that’s what I’m using.

This one is to increase the time advancement:

    The fast time rule is listed instead of the advance time rule in the turn sequence rules. 

This is the fast time rule:
    increment the turn count;
    increase the time of day by 5 minutes. 

And this one is to set the day/night cycle:

The sun is a backdrop. It is everywhere. The description is “Currently out of sight.”
Night is a recurring scene. Night begins when play begins. Night begins when Dusk ends. Night ends at 6:00 AM.

When Night begins:
say “The sun falls below the horizon and the temperature drops abruptly to well below zero.”;
now the description of the sun is “Currently out of sight.”

Dawn is a recurring scene. Dawn begins when Night ends. Dawn ends at 10:00 AM.

When Dawn begins:
say “The sun appears on the horizon.”;
now the description of the sun is “It is tiny and weak.”.

Day is a recurring scene. Day begins when Dawn ends. Day ends at 6:00 PM.

When Day begins:
say “The sun is now properly up.”

Dusk is a recurring scene. Dusk begins when Day ends. Dusk ends at 10:00 PM.
When Dusk begins:
say “The sun has passed across the sky and is on the verge of setting.”

Cratered Landscape is a room. “The ground here is [if Night is happening]dim silver, with the craters visible as darker splotches[otherwise]the color of dried blood; here and there it is also rippled by impact craters[end if]. The horizon curves visibly.”

Problem:

Well first of all the "X ends at Y code don’t work for me. I know I must be doing something wrong and I need your help for that. But that is not the main problem.

The main problem is that my time of day is broken. After 11 AM is says 12 PM (this is okay), but after 11 pm it stays at 12 pm and then continue at 13,14,15,16 PM… It don’t know why it’s doing that. I tryed reinstalling Inform 7 but it’s still broken. Maybe I could use a code to fix it?

Thanks for your help :slight_smile:.

Yes, it seems the Uptempo example in the Recipe Book misses to make the necessary adjustments to the hours part of time of day when it reaches 13. Your fast time rule should look something like this:

This is the fast time rule:
	increment the turn count;
	increase the time of day by 5 minutes;
	if the hours part of time of day >= 13:
		decrease the time of day by 12 hours;
		increase the time of day by 12 hours.

Normally those adjustments are made by the Advance Time Rule, but of course the whole point of the fast time rule is to replace the Advance Time Rule, so we need to make the adjustments ourselves.

Alternatively, you could skip the fast time rule and set the number of minutes per turn thus:

The time rate is a number that varies. The time rate variable translates into I6 as "time_rate". When play begins: now the time rate is 5.

The time_rate is the I6 global variable that determines how many minutes a turn takes. It is used by the Advance Time Rule as such, so in this case we can rely as normal on the standard Advance Time Rule to fix the passage from 12:59pm to 1:00pm.

From the source text you’ve posted it would seem that the problem is this.
Night begins when play begins. But by default play begins at 9:00 am. So the first night of your game begins at 9:00am. Then Night doesn’t end till 6:00am, which won’t occur till early next morning. So the first night of your game will last for 21 hours.

If you want your game to start in the middle of the night, you need an assertion to that effect in the source text:

The time of day is 12:00 AM.

or

When play begins: now the time of day is 12:00 AM.