Thanks for the responses. The ‘Any’ token was what I was missing primarily.
I had already seen Emily Short’s transit systems but none of them were really suitable. I have settled on something a little less complex than I originally intended because I felt objects / rooms that move on a schedule were too clunky and unreliable, so instead I have a system using a special kind of room (the bus stop), a universal backdrop (the bus schedule) and a set of tables, each of which indicates the amount of time it takes to get from one bus stop to any other connected bus stop.
Pros:
- Simplicity - you just type ‘catch a bus to [place]’
- Immediacy - no waiting around for objects to turn up.
- Adaptability - buses can have different transit times to different places.
- Extendability - I can turn buses off by commenting out their entries in the tables, or add more as I like.
Cons:
- Catching the bus doesn’t trigger going to overrides.
- Possible issues with changing time of day directly.
Here’s the code:
[code][bus timetables]
Table of Village Transit Times
start name duration
City Centre “City Centre” 60
Table of City Centre Transit Times
start name duration
Village “Village” 60
[Code for bus stop room kind.]
A bus stop is a kind of room. The bus stop has a table name called schedule.
[Code for catching a bus to a known destination.]
Catching a bus to is an action applying to one visible thing.
Understand “catch bus to [any bus stop]”, “catch a bus to [any bus stop]”, “catch the bus to [any bus stop]”, “catch bus for [any bus stop]”, “catch a bus for [any bus stop]” or “catch the bus for [any bus stop]” as catching a bus to.
Check catching a bus to:
if the player is not in a bus stop:
say “This isn’t a bus stop.” instead;
otherwise if the player is in the noun:
say “But I’m already there!” instead;
otherwise if there is no duration corresponding to a start of noun in the schedule of the location of the player:
say “I don’t think there’s a bus to [the noun] from this stop. I’d better check the bus schedule.” instead;
Carry out catching a bus to:
choose row with a start of the noun in the schedule of the location of the player;
now time of day is time of day plus duration entry minutes;
move the player to the noun.
Report catching a bus to:
say “I grab a bus to [the noun].”;
[Code for catching a bus if the player forgets to name a destination.]
Catching an unknown bus is an action applying to nothing.
Understand “catch bus”, “catch a bus” or “catch the bus” as catching an unknown bus.
Check catching an unknown bus:
if the player is not in a bus stop, say “This isn’t a bus stop.” instead;
Report catching an unknown bus:
say “I ponder briefly where I’d like to go next. Perhaps I should check the bus schedule? There’s one at every bus stop.”
[The bus schedule can be checked at bus stops to find out what destinations are available.]
The bus schedule is a thing. It is a backdrop. It is everywhere.
Understand “timetable” and “bus stop” as bus schedule.
Instead of examining the bus schedule:
if the player is not in a bus stop:
say “This isn’t a bus stop.”;
otherwise:
say “[bold type]Bus Schedule for [the location][roman type][line break]” in title case;
repeat through schedule of the location of the player:
say “[name entry] -:- [italic type][duration entry] minutes[line break][roman type]”
[The bus stop rooms themselves]
The Village Bus Stop is a bus stop. “A quiet country village.” The schedule of the village bus stop is the Table of Village Transit Times.
The City Centre Bus Station is a bus stop. “The bustling city.” The schedule of the city centre bus station is the Table of City Centre Transit Times.[/code]