# Time of Day script

Hi guys, I’ve been using this time of day script I borrowed off of the forums here somewhere and it worked great until I used the wait command just now and it started running the ‘roll over new day’ script on an infinate loop every time you use the ‘wait 1 hour’ command. The thing is that it worked fine before and I can’t tell what might have started messing with it. Can anyone see what’s wrong with it?

[code]

Section - TIME

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:
otherwise:
say “The time is [time of day + 1 minute].”;

Report time-checking:
if no timepiece is visible,
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:

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…”

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;
Say “[line break]Midnight! A new day comes…”;
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;
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;

At the time when we need to enqueue the timed event:
the DayRollsOver at 12:00 am;[/code]

This works fine when I try it (adding an appropriate Table of Months). Is there some other part of your code that could be interacting with this part?

I note that the method of calling the turn sequence rules many times in response to a single command requires you to be a little careful with ‘every turn’ rules. For example, consider something like:``` Every turn: if the player has been in the Danger Zone for three turns, trigger the disaster. ```If the player waits in the Danger Zone for 1 hour, the “trigger the disaster” phrase will be called dozens of times, whereas the desired behavior is probably to call it once and terminate the waiting.