Doing the comparison has been more tricky than I realized as the date values (Month, Day, Year) stored by the extension are independent and have no relation to each other. As in, there’s no easy way to compare a date like December 15, 2021 to January 26, 2022. Crossing years like that is especially tricky.
Best I can figure is to assign a value to the day based on where it falls within the 365-day calendar. Assign a value to the save game file’s day and then assign a value to “today’s” day, the date the player restores the file. Then, compare the distance between them. Since the intent of this is to display a message to the player when they’re been away from the game for a while (reminding them of available verbs, hint system, etc) I figure after a certain length of time we can stop worrying about being specific: the player hasn’t played in a long time, whether that’s six months or six years.
I’m too much of a coward to go messing with my laptop’s system clock not having done it before, but maybe tonight I can dig out my old laptop. This is what I’ve got so far:
Include Real Date and Time by Ron Newcomb.
The save the game rule response (B) is "[italic type]Ok, game saved.[roman type]".
The restore the game rule response (B) is "[italic type]Restored.[line break][RestoreGameMessage][roman type]".
First carry out saving the game (this is the store date data when saving rule):
if the player's time is available:
now SaveGameMonth is the player's month;
now SaveGameDay is the player's day;
now SaveGameYear is the player's year;
now BaseSavedDay is 0;
now BaseTodayDay is 0;
now TotalDaysPassed is 0;
The Laboratory is a room. "There are many scientific instruments here.".
[core saved values updated upon save]
SaveGameMonth is a month that varies.
SaveGameDay is a number that varies.
SaveGameYear is a number that varies.
BaseSavedDay is a number that varies. [Sets the number of days that have occurred in the year up until that month. Then, we'll add the GameSaveDay to it. e.g. February 5 is 31 + 5 = 36; 31 days in January and then 5 days into February. This is for the save file.]
BaseTodayDay is a number that varies. [We do the same with this variable. This is for the date "today" when the player has restored the game file. Now, we're able to compare the two variables and calculate the difference between them.]
TotalDaysPassed is a number that varies. [When we compare the two Base variables (subtract BaseTodayDay by BaseSavedDay) we store the resulting number here.]
TotalYearsPassed is a number that varies. [Things get screwy if the player goes a very long time between saving and restoring. So, it's necessary to separate out if/thens based on how many years have gone by.]
To say RestoreGameMessage:
if the player's time is available:
if SaveGameYear is the player's year: [the save file is the same year as the restore date]
if the SaveGameMonth is January, now BaseSavedDay is 0; [giving the two variables a base value]
if the player's month is January, now BaseTodayDay is 0;
if the SaveGameMonth is February, now BaseSavedDay is 31;
if the player's month is February, now BaseTodayDay is 31;
if the SaveGameMonth is March, now BaseSavedDay is 59;
if the player's month is March, now BaseTodayDay is 59;
if the SaveGameMonth is April, now BaseSavedDay is 90;
if the player's month is April, now BaseTodayDay is 90;
if the SaveGameMonth is May, now BaseSavedDay is 120;
if the player's month is May, now BaseTodayDay is 120;
if the SaveGameMonth is June, now BaseSavedDay is 151;
if the player's month is June, now BaseTodayDay is 151;
if the SaveGameMonth is July, now BaseSavedDay is 181;
if the player's month is July, now BaseTodayDay is 181;
if the SaveGameMonth is August, now BaseSavedDay is 212;
if the player's month is August, now BaseTodayDay is 212;
if the SaveGameMonth is September, now BaseSavedDay is 243;
if the player's month is September, now BaseTodayDay is 243;
if the SaveGameMonth is October, now BaseSavedDay is 273;
if the player's month is October, now BaseTodayDay is 273;
if the SaveGameMonth is November, now BaseSavedDay is 304;
if the player's month is November, now BaseTodayDay is 304;
if the SaveGameMonth is December, now BaseSavedDay is 334;
if the player's month is December, now BaseTodayDay is 334;
increase BaseSavedDay by SaveGameDay; [adding the day of the actual month to give the two variables their true "rank"]
increase BaseTodayDay by the player's day;
let TotalDaysPassed be BaseTodayDay minus BaseSavedDay; [the distance between the two values is stored here]
if TotalDaysPassed < 7 and TotalDaysPassed > 0:
say "Less than a week has passed ([TotalDaysPassed] days; [SaveGameMonth] [SaveGameDay], [SaveGameYear]) since the creation of this save file.";
otherwise if TotalDaysPassed is 0:
say "Your last save was today.";
otherwise if TotalDaysPassed >= 7 and TotalDaysPassed < 32:
say "Over a week ([TotalDaysPassed] days; [SaveGameMonth] [SaveGameDay], [SaveGameYear]) has passed since this save file was created.";
otherwise if TotalDaysPassed >= 32:
say "Over a month ([TotalDaysPassed] days; [SaveGameMonth] [SaveGameDay], [SaveGameYear]) has passed since this save file was created."; [You could keep going with various messages and measurements (3 months, six months, etc) but this felt like more than enough.]
otherwise if SaveGameYear < the player's year:
let TotalYearsPassed be the player's year minus SaveGameYear;
if TotalYearsPassed > 1: [You could add in multiple different messages exclaiming how many years have past since the save file, but "more than 1" seems sufficient. Also, only accounts for the year, the number, changing and not partial years having passed. e.g. January 1, 2023 to December 31, 2024 is counted as one year difference even though common sense says two]
say "More than a year has passed since this save file was created. ([SaveGameMonth] [SaveGameDay], [SaveGameYear])";
otherwise if TotalYearsPassed is 1 and the SaveGameMonth is December and the player's month is January:
increase BaseSavedDay by SaveGameDay; [similar logic to the first section above, but shrinking things down to just look at the passage of time between December and January. BaseSavedDay starts at 0 and then is increased depending on the number of days into December. BaseTodayDay starts at 31 since December is over, and then adds the number of January days that have passed]
now BaseTodayDay is 31;
increase BaseTodayDay by the player's day;
let TotalDaysPassed be BaseTodayDay minus BaseSavedDay;
if TotalDaysPassed < 7 and TotalDaysPassed > 0:
say "Less than a week ([TotalDaysPassed] days; [SaveGameMonth] [SaveGameDay], [SaveGameYear]) has passed since the creation of this save file.";
otherwise if TotalDaysPassed >= 7:
say "Over a week ([TotalDaysPassed] days; [SaveGameMonth] [SaveGameDay], [SaveGameYear]) has passed since this save file was created.";
otherwise if TotalYearsPassed is 1 and the SaveGameMonth is December and the player's month is not January:
say "Over a month ([TotalDaysPassed] days; [SaveGameMonth] [SaveGameDay], [SaveGameYear]) has passed since this save file was created."; [this is a little bit of a shortcut as you'd have to copy all the crazy month math we do in first section above, but then throw on December's days. I figure it's not worth it.]
otherwise if TotalYearsPassed is 1 and the SaveGameMonth is not December:
say "Over a month ([TotalDaysPassed] days; [SaveGameMonth] [SaveGameDay], [SaveGameYear]) has passed since this save file was created."; [Ditto here.]