Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
Tutorial explaining the anatomy of a verb in Adventurejs. tutorial, verb anatomy

Customize Verbs:Anatomy of a Verb

Adventurejs's verbs fall into a small number of patterns. There are direction verbs, which are fairly simple and quickly punt to a global tryTravel() method. The bulk of verbs have to do with physical manipulation. (Well, "physical" manipulation. Since of course it's all virtual.) For example, lock, unlock, hit, throw, and write are just a few common physical manipulation verbs. Most of these verbs' code structures will look something like the diagram below. The diagram doesn't represent any particular verb, as every verb has its own quirks. Some of the blocks shown below may exist in some verbs but not others, and some of the function calls may or may not be used by any verb. But hopefully this will offer some idea of how a verb is constructed.

  • String properties: name, prettyname, state, past_tense, etc
  • phrase3
    Phrases work with structures to help the parser exclude input that the verb can't handle, before it reaches the verb. The majority of verbs have only one or two phrases. Some verbs may have three. For example, attach pipe to flange with wrench would take three phrases, one for each noun in the input. Phrases can help the parser determine whether the verb accepts or requires a preposition, what that preposition must be, and what conditions must be true for any noun that the verb refers to.