Section - Extended Waiting
[ Two forms of waiting which are often tried by players in a game with a day/night system-- waiting for a certain time and waiting for a certain *amount* of time. First some utility functions:]
To decide which time is the time corresponding to (moment - an interval):
if moment is dawn, decide on 4:01 AM;
if moment is sunrise, decide on 5:01 AM;
if moment is morning, decide on 5:10 AM;
if moment is midmorning, decide on 7:01 AM;
if moment is midday, decide on 10:31 AM;
if moment is afternoon, decide on 2:31 PM;
if moment is evening, decide on 5:31 PM;
if moment is sunset, decide on 7:01 PM;
if moment is twilight, decide on 7:20 PM;
if moment is night, decide on 8:01 PM;
decide on 12:01 PM.
To decide what number is the number of minutes between (starttime - a time) and (endtime - a time):
[ The math goes wrong if we do this too fast for some reason...]
let startt be the hours part of starttime;
if startt > 12, decrease startt by 12;
now startt is startt * 60;
if starttime is after 12:59 PM and starttime is before 12:00 AM, now startt is startt + 720;
increase startt by the minutes part of starttime;
let endt be the hours part of endtime;
if endt > 12, decrease endt by 12;
now endt is endt * 60;
if endtime is after 12:59 PM and endtime is before 12:00 AM, now endt is endt + 720;
increase endt by the minutes part of endtime;
let finalt be endt - startt;
if finalt < 0, increase finalt by 720;
decide on finalt.
[ Map a command like "wait till sunset" to waiting for a specific amount of time.]
Understand "wait til/till/until/for [an interval]" as waiting until. Waiting until is an action applying to one interval.
Check waiting until:
if location is not regionally in Lacuna, say "[if location is regionally in Dreamlands]You're not sure whether time passes or not[else]There's too much at stake to just wait around right now[end if]." instead.
Check waiting until:
if current interval is the interval understood, say "It's [current interval] now." instead.
Check waiting until:
if the interval understood is low tide or the interval understood is high tide, say "You don't know the tides here well enough to be sure when that might be, but you can try waiting for a certain number of hours, or until a certain time of day." instead.
Carry out waiting until:
let target time be the time corresponding to the interval understood;
try waiting for ( 12:01 AM + the number of minutes between the time of day and target time minutes - 1 minute ) instead.
[ Now understand waiting for a specific amount of time. Because of the way episodes are triggered, we have to be careful not to skip over things that should be happening at certain times.]
Understand "wait for [a time period]" or "wait [a time period]" as waiting for. Waiting for is an action applying to one time.
Check waiting for:
if location is not regionally in Lacuna, say "[if location is regionally in Dreamlands]You're not sure whether time passes or not[else]There's too much at stake to just wait around right now[end if]." instead.
Carry out waiting for:
if the heavens are being debugged, say "**waiting for [the time understood]**";
if the time understood > 8 hours, say "You can't just wait around for that long." instead;
if the time understood < 5 minutes, speak as the parser "In the future, to wait for just a few minutes you can simply type WAIT." instead;
if current interval is night, say "If you try to wait that long, you're likely to fall asleep. Better find a good spot for that." instead;
if an attentive other person is enclosed by location, say "That would be rude to do while you're in the middle of this discussion." instead;
if an episode is playing, say "You find you are too keyed up just now to wait around." instead;
let old-time be the time of day;
let old-interval be current interval;
let new-time be the time understood;
if ambience_on is 1, say "You pace restlessly as the time passes[time-of-day-bit].";
let totaltime be new-time;
increase totaltime by the time of day;
if the heavens are being debugged, say "**about to test 'while the time of day [the time of day] < the time of day + new-time ([new-time]) (which is [totaltime]) and an attentive other person is not enclosed by location ([if an attentive other person is not enclosed by location]yes[else]no[end if])'**";
while the time of day < totaltime and the number of attentive people is 0 begin;
if the heavens are being debugged, say "**yes**";
increase the time of day by new-time; [ This is temporary; we'll set it back and use the proper "pass x minutes" method in a moment.]
if the heavens are being debugged, say "%[the time of day]%%[current interval]%";
update interval;
change the time of day to old-time;
if the heavens are being debugged, say "**about to test whether current interval [current interval] > old-interval [old-interval]";
if current interval > old-interval or ( current interval is night and current interval < old-interval ) begin; [ if the total amount of waiting time remaining switches us to a new interval, we need to change so that we're only advancing one interval's worth of time. This is because certain events may be triggered by the transition to a certain interval, so we need to give them a change to fire and potentially interrupt the waiting.]
if the heavens are being debugged, say "**yes**";
if old-interval is night, let tmptime be the time corresponding to dawn;
else let tmptime be the time corresponding to the interval after old-interval;
if the heavens are being debugged, say "**old-time: [old-time]; tmptime: [tmptime]; mins: [the number of minutes between old-time and tmptime]; old-interval: [old-interval]; current interval: [current interval]**";
pass ( the number of minutes between old-time and tmptime ) minutes of time;
if old-interval is night, now old-interval is dawn;
else now old-interval is the interval after old-interval;
if the heavens are being debugged, say "**decreasing new-time [new-time] by [the number of minutes between old-time and tmptime] minutes --> ";
decrease new-time by ( the number of minutes between old-time and tmptime ) minutes;
if the heavens are being debugged, say "[new-time] (-3 mins)**";
now old-time is the time of day;
else;
if the heavens are being debugged, say "**no**";
decrease new-time by ( the number of minutes between the time of day and totaltime ) minutes;
pass ( the number of minutes between the time of day and totaltime ) minutes of time;
end if;
decrease new-time by 3 minutes; [ to account for the time that will pass when we follow the turn sequence rules.]
if the heavens are being debugged, say "**following turn sequence**";
follow the turn sequence rules;
now totaltime is new-time;
increase totaltime by the time of day;
if the heavens are being debugged, say "**about to test 'while the time of day [the time of day] < the time of day + new-time ([new-time]) (which is [totaltime])'**";
end while;
if ambience_on is 1, try looking.