[help] Time 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.”


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 .

Sorry, I just answered your question (as best I could) at the ”Getting Started Playing” forum before I saw this post. You’re quite right that the question (and the answers) should rather go here. Or perhaps even more appropriately at the “Inform 6 and 7” forum below.
Good luck with the game!

I should of course repost the replies. Here they are:

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.


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

Thanks for answering, all is fine now :slight_smile:.

But if you have the time, could you answer another question please?

Let’s say I want to make a city. In an area, I want to be able to enter in several houses. But when you only type “enter”, it says something like that: What location do you want to get in? (Could be better :stuck_out_tongue:).

I already tryed to do:


Room1 is a room.

Room2 is a room. Room2 is inside from room1.

Room3 is a room. Room3 is inside from room2.

But it don’t work. Do you have any tips? :smiley:

Edit: Sorry, I made a mistake:


Room1 is a room.

Room2 is a room. Room2 is inside from room1.

Room3 is a room. Room3 is inside from room1.

The main issue is that “enter” means “enter container”; Inform recognizes “in” as synonymous for going inside, and enter as going inside a container - a booth, or a large box.

This is a bit more complicated than it appears, as you need to know what you want the player experience to look like, and you need to know something about how you’re going to use enterable containers. (For example, if you’re never going to use them at all, you might just replace the command entirely.)

You could change the noun to “inside” when none has been given and then change the action to the going action. Try this:

[code]Rule for supplying a missing noun while entering and the room inside from the location is a room:
change the noun to inside.

Before entering inside:
try going inside instead.[/code]

If I understand you right, you want to be able to type ENTER to enter any room. And you tried to achieve that by relating them by the inside direction, which didn’t work.

The rules for the entering action assumes that only containers, supporters, doors and directions should be entered. And we cant add any rules for entering rooms, because the entering action is not defined as applying to things anywhere else than the current location. And another room is by definition somewhere else (even if it happens to be inside from the room where you are).

The rules for the going action doesn’t let you specify a room to go to either (on ly a direction to go in or a door to go through). But in this case we can add rules to make it possible, since the going action is defined as applying to things anywhere in the game world.

After that we can redirect the command ENTER to mean going rather than entering.

We can let the player specify a room to go to by changing one of the check going rules in the Standard rules:

Check an actor going (this is the new determine map connection rule):
	repeat with portal running through visible doors:
		if the noun is the other side of the portal, try going the portal instead;
	let the target be nothing;
	if the noun is an adjacent room:
		now the target is the noun;
	if the noun is a direction:
		let direction D be the noun;
		let the target be the room-or-door direction D from the room gone from;
		if the noun is a door, let the target be the noun;
	if the target is a door:
		now the target is the other side of the target from the room gone from;
	now the room gone to is the target.

The new determine map connection rule is listed instead of the determine map connection rule in the check going rules.

This will replace one of the standard rules with a new one, in which we have added a few lines (lines #2, 3, 5 and 6) to let the player go to the specified room if it is adjacent or there is a visible door that leads to it.

Now we could add merely »Understand “enter [any room]” as going.» and the game would understand commands such as ENTER LIBRARY as going to the library. However, it would still understand simply ENTER as entering a container or a supporter or a door, which means that if you type ENTER in a room where there is only one of these the player will enter that thing without asking any questions.

A solution that preserves most of the default behaviour, is to create a new action that can serve as a middle hand and redirect ENTER commands to the entering or the going action as appropriate:

Intruding is an action applying to one visible thing.
Check intruding:
	if the noun is a room, try going the noun;
	otherwise try entering the noun;
	stop the action.

Understand the command "enter" as something new.
Understand "enter" as intruding.
Understand "enter [something]" as intruding.
Understand "enter [any room]" as intruding.

And while were at it, we can define a couple more relevant commands:

Understand "go to [any room]" as going.
Understand "go [any room]" as going.

This seems to work reasonably well. But it isn’t thoroughly tested, so may or may lead to bugs and may or may not clash with any Inform extensions you choose to include.

Since this is a non-standard use of the command ENTER many players will not think of using it; therefore you should somehow hint that it’s possible to ENTER A ROOM in your game.
On the other hand, it’s a command that new players, who are not already conditioned to the conventions of IF (or at least to the conventions of Inform – and of TADS, I guess (I really don’t know what games I’ve played were written in TADS and what in Inform)), may very reasonably try.
So, I suppose, it may be worth the while to provide such an ENTER ROOM command.