Calender extension for Inform 7?

I’ve recently been trying to make a life sim in Inform, and for this I kinda need an in-game date. I’m not too fond of the prospect of making this myself, so does anyone know of any extensions that fill this role? Or if anyone could teach me how to make it I would be happy to listen and give it a shot.

It just so happens that I slapped together something for this last week, so I’ll just past it here for you. The days and months advance automatically, so all you have to do is set the date (for example, When Play Begins) via:

now the current day of week is Thursday;
now the current day is 16;
now the current month is April;

You could write code that would allow you to merge these into a single declaration with a little tinkering, of course, but I never bothered. And of course if you want to display the current date in game, as I’m sure you can guess, just do:

say "[current day of week], [current month] [current day]"

Or, of course, whatever format you prefer/is appropriate for your region. Anyway, here’s the code I wrote:

Day is a kind of value. The days are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. The current day of week is a day that varies.

The current day is a number that varies.

Month is a kind of value. The months are defined by the Table of Months. The current month is a month that varies.

At 11:59 PM:
	increase the current day by 1;
	if the current day is greater than the length of the current month:
		now the current day is 1;
		now the current month is the month after the current month;
	if the current day of week is Saturday:
		now the current day of week is Sunday;
	otherwise:
		now the current day of week is the day after the current day of week.

Table of Months
month	length
January	31
February	28
March	31
April	30
May	31
June	30
July	31
August	31
September	30
October	31
November	30
December	31

Didn’t the “Weather” extension model date also?

Thanks! I didn’t know you could use tables to achieve this easily, so thanks for showing.

Glad I could help. Tables can indeed be used to define values. They can also be used to create a bunch of items all at once. Those items can even be created in the context of a relation! For example, you can say “Some things carried by Valerie are defined by the Table of Valerie’s Stuff”, and anything you list in the Table of Valerie’s Stuff will be in Valerie’s inventory. It’s nifty.

Thanks to dfremont there a now way to make sure that this script increases the days at midnight every single day.

[code]A timepiece is a kind of thing.

A watch is a portable timepiece. A clock is a timepiece.

A general time is a kind of value. The general times are defined by the Table of Apparent Time.

Table of Apparent Time
general time start time
early morning 4:00 AM
dawn 6:00 AM
morning 7:00 AM
mid-morning 9:00 AM
mid-day 11:00 AM
lunch-time 12:00 AM
afternoon 1:00 PM
mid-afternoon 3:00 PM
early evening 5:00 PM
dusk 7:00 PM
evening 9:00 PM
night 11:00 PM
late night 2:00 AM

Time-checking is an action applying to nothing.

Report time-checking:
if no timepiece is visible:
say “It feels about [the current general time].” instead;
otherwise:
say “The time is [time of day + 1 minute].”;

Report time-checking:
if no timepiece is visible,
say “It feels about [the current general time].” instead;
otherwise say “The time is [time of day + 1 minute].”

Understand “check time” and “time” as time-checking.

To decide what general time is the current general time:
let T be a general time;
repeat through the Table of Apparent Time:
unless the time of day is before the start time entry, now T is the general time entry;
decide on T.

Waiting more is an action applying to one number.

Understand “wait [a time period]” or “wait for [a time period]” or “wait for a/an [a time period]” or “wait a/an [a time period]” as waiting more.

Carry out waiting more:
let the target time be the time of day plus the time understood;
decrease the target time by one minute;
while the time of day is not the target time:
follow the turn sequence rules.

Check waiting more:
if the time understood is greater than 4 hours, say “You really don’t feel like waiting around that long.” instead.

Report waiting more:
say “You wait…”

[After going:
increase the time of day by 10 minutes;]

Day is a kind of value. The days are Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday. The current day of week is a day that varies.

The current day is a number that varies.

Month is a kind of value. The months are defined by the Table of Months. The current month is a month that varies.

When play begins: the DayRollsOver at 12:00 am.

At the time when the DayRollsOver:
increase the current day by 1;
we need to enqueue the timed event in 30 minutes from now;
if the current day is greater than the length of the current month:
now the current day is 1;
now the current month is the month after the current month;
Say “[line break]A new day comes…”;
if the current day of week is Saturday:
now the current day of week is Sunday;
Say “[line break]A new day comes…”;
otherwise:
now the current day of week is the day after the current day of week;
Say “[line break]A new day comes…”;
At the time when we need to enqueue the timed event:
the DayRollsOver at 12:00 am.

Table of Months
month length
January 31
February 28
March 31
April 30
May 31
June 30
July 31
August 31
September 30
October 31
November 30
December 31

To say CurrentDate:
say “[current day of week], [current month] [current day]”.
[/code]