Catching the Bus

I’ve been pondering on this for a while and have tried a few solutions, all of which are either cumbersome in the extreme or simply did not work.

What I want to do is implement a public transport system. I started off with scheduled timers that move an object, but since I need several buses, each would need to be copy/pasted rather than sharing code and the timers aren’t guaranteed to fire which could throw things out when waiting for extended periods of time. This didn’t seem too great an option.

So I thought I’d instead implement a custom command called ‘catch the bus to [x]’ which only worked at bus stops and then only to destinations I chose. However I’m still having difficulty because the command has to be targeted at a ‘thing’ and I can’t seem to move the thing into scope - all I get is ‘you can’t see that’ type messages.

Has anyone implemented anything similar to this, or does anyone know of a useful extension or plug-in for this kind of work?

Looks like another job for the [any …] grammar token:

[code]North Street is a room. Main Street is a room. MLK Drive is a room. West 45th is a room.

Instead of going, say “It’s way too hot to walk today. Take the bus instead.”

Catching is an action applying to one visible thing.

Understand “catch a/the/-- bus to [any room]” as catching.
Understand “take a/the/-- bus to [any room]” as catching.

Carry out catching:
move the player to the noun, without printing a room description.

Report catching:
say “Five minutes and $1.10 later, the bus drops you off at [noun].”;
try looking.

Test me with “n / take the bus to main street / catch bus to mlk / catch bus / street / main”[/code]

The [any …] token puts whatever fits the description after the word “any” into scope for the purpose of parsing that particular command. In this case, [any room] means that within the context of the catching command, all rooms are in scope and can be referred to by the player. (Note that the action definition says it applies to “one visible thing” – the [any room] token makes every room visible.) It’s a pretty handy tool.

You may want to look over Transit System by Emily Short (In the IDE extension library).

Transit System provides a system for trains, buses, ferries, and other vehicles that might make regular stops at different places on the map for the player to mount and dismount.

This may do what you want, or possibly provide some ideas if you peruse the source text.

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.


  • 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.


  • 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.”;
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]