I want to be able to arbitrarily advance the time of day, either at the player’s request (like a “wait 10 minutes” command), because their action is something that should take awhile (for example “search notes for [topic]” should probably take longer than “examine kitchen sink”), or just because an event has occurred that takes some time.
I realize it’s possible to just say now the time of day is 12:01 PM
or whatever. However, I want to make sure that amy running scenes are properly updated, and I don’t want it to clobber Every Turn rules, either. (Actually, something that happens in an Every Turn rule should probably be given the opportunity to cancel the wait early, at least if it’s player-initiated, but that’s not really related to my issue here.)
So far, I’ve implemented the first of those – an action that waits for a specified period of time. It works really well… until the end of the day, that is. Once the time of day wraps around to the next day, scenes that are ongoing frequently stop working. For example, if they were supposed to end during the wait, they don’t; and the scenes
command notes that the time they’ve been playing has decreased and is often negative. Not all scenes will break, however, only the ones that have been running for more than a certain length of time and which depend on time to determine whether they’ve ended. It also seems to break down if I wait 24 hours or more, which isn’t that big of a deal for player-initiated waits (I’d probably set a maximum time) but might become a problem if I want to do a “you got knocked out cold for 3 days” event.
I’m currently working around it by making sure any especially long-running scenes don’t end based on time of day or time since they began, but I wondered if there’s a way to fix the issue itself, whether it’s a bug in the standard rules or I’m doing something wrong in my code
This is the implementation of my waiting action. (I don’t remember why I have an “advancing time” variable.) That code would probably be moved to a phrase later so I can invoke it from other places, but this is fine for testing that it works.
Advancing time is a truth-state that varies.
Waiting more is an action applying to one number.
Understand "wait for/-- a/an/-- [a time period]" or "z [a time period]" as waiting more[ when the use waiting for a duration command option is active].
Carry out waiting more (this is the standard waiting more rule):
now advancing time is true;
[This block allows waiting more than a day, but I don't think that's useful…]
[let the days be the time understood divided by 24 hours;
while the days are greater than zero:
let the next day be the time of day minus one minute;
while the time of day is not the next day:
follow the turn sequence rulebook;
follow the turn sequence rulebook;
decrease the days by one;]
[This is the most important part of the logic.]
let the target time be the time of day plus the time understood;
if the time understood is at least 10 minutes:
let the target time be the target time plus a random time from -5 minutes to 5 minutes;
decrease the target time by one minute;
while the time of day is not the target time:
follow the turn sequence rulebook;
now advancing time is false.
Report waiting more (this is the report waiting more rule):
say "You wait for about [the number understood in words] minutes."
I was fiddling around with that code in a small test scene, something like this, playing around with the conditions for when the scenes begin and end, and using the scenes
command followed by various variations on z 12 hours
.
Advancing time is a truth-state that varies.
Waiting Area is a room. The mystical item is a thing. At 9:00 PM: say "[The mystical item] appears!"; now the mystical item is in the Waiting Area.
Happenstance and Opportunity are recurring scenes. Happenstance begins when play begins.Happenstance begins when Happenstance ends. Happenstance ends when the time since Happenstance began is at least 90 minutes. Opportunity begins when the player carries the mystical item. Opportunity ends when the time since Opportunity began is at least 90 minutes.
When play begins:
now the command prompt is "[time of day]> ".
One other thing I wondered is whether it’s even okay to invoke the turn sequence rulebook from an action, as it seems to violate the constraints laid out in chapter 10.9 of Writing with Inform. I haven’t tried any alternative approaches yet, though.
This approach also has poor performance – for longer periods of time, there’s a very noticeable lag when waiting.