A TADS3/adv3 module to make it easier to refer to Rooms in actions

Here’s a little module intended to make it easier to refer to rooms and exits in actions: roomVocab github repo.

The basic “problem” this is intended to solve is that, by default, a Room doesn’t get any vocabulary and so if you define a room like:

startRoom: Room 'Void' "This is a featureless void. ";

…you get…

>x void
The word "void" is not necessary in this story.

>x room
The word "room" is not necessary in this story.

The stock adv3 Template for Room includes the optional properties destName and name, but not vocabWords. You can just declare vocabWords on a Room, but not using the stock Template.

Anyway, the module does a couple things:

  • Provides an alternate template that includes vocabWords
  • Defines a PreinitObject looks for Rooms without vocabWords and initializes their vocabulary with roomName + the literal “room”. Rooms with declared vocabularies aren’t affected.
  • Modifies Room to use a room’s destName as its disambigName by default
  • Modifies Room to add all rooms adjacent to the gActor’s current location to the scope list
  • Modifies Room to provide a mustBeVisibleMsg that checks to see if the room is adjacent to the gActor and returns a different failure message if it is. This is so trying to interact with an adjacent room produces a distinct failure message (&roomUnseenAdjacent, by default “If you want to do anything with [room name], you should go there first.”) instead of the default (&mustBeVisibleMsg, by default “You cannot see that”).
    This applies to all verbs using the objVisible precondition, and any precondition that uses TouchObjCondition (which includes most sense actions). Non-adjacent rooms are unaffected.

The module also provides some utility methods on Room that might be more generally useful, like:

  • isAdjacent(actor, rm) Returns boolean true if there’s an exit leading from the actor’s current location to the given room.
  • exitList(actor?, cb?) Returns a list of all the exits apparent to the given actor (defaulting to gActor if the first arg is nil). The second argument is an optional test function (taking two arguments: the direction and destination of a candidate exit and returning true if the exit should be added to exitList()'s return value)
    Each entry in the return value is an instance of DestInfo
  • destinationList(actor?, cb?) Similar to exitList(), but returns a list of destinations (probably Rooms) instead of DestInfo instances

This is another fairly small module (just a couple hundred lines), but it’s one of those things where I found myself writing “make it easier to refer to rooms/exits” code in a couple contexts (NPC dialog, fast travel, non-compass travel, tracking NPC/player memories/knowledge) so I decided to break it out into its own module.

I think most of this is adv3-specific, because I think adv3lite already makes it easier to refer to rooms than adv3 does.


Yes, I believe it does.

1 Like

Lol, at some point I will have more of your modules than my own code! The lack of vocab in the template has always grated me too. A smarter person than me would have changed the template long ago.

Then released it as a module for the community!


1 Like

Yep, I made my own mods to get room vocab and interaction too…