Getting Started:Debug the Game
When a player tries to do something that they can't do, the game tries to tell them why. For instance:
> climb wall There doesn't appear to be any wall present.
AdventureJS has over a thousand built-in messages like this, to handle situations like: the player used an unknown word, tried to get on a thing they're already on, tried to use a door that doesn't exist, tried to climb a thing that's not climbable, tried to take a thing that's not takeable, tried to speak to a character who's not present, tried to use a sentence structure with a verb that doesn't support it, etc, etc, etc. All these things and many, many more will print a message telling the player they can't do the thing they just tried to do.
It's possible that this wasn't what the author intended. To help track down unknown or undesirable responses to user input, AdventureJS offers detailed debugging information to help authors understand exactly what logic prevented the player from doing the thing. Here is a very brief example.
This debug message, though brief, tells us quite a bit. The message serial
number D1067 can be used to find the exact line in the
AdventureJS source code that generated the response. climb tells
us that the message came from the verb climb.
phrase1.noun.must_be.present tells us that the verb climb
requires a direct object to be present for the verb to act upon it.
In our example game below, we've enabled
game.settings.debug.general. This is the most basic debug
feature. In fact, AdventureJS offers considerably more debugging information,
and we'll cover that in
Debugging: Debug in Game
and
Debugging: Debug in Console. For now,
try playing the game below to see what debug info you can see. Here are some
commands you might try:
- go south
- unlock door
- fly
- eat brick
- eat cobblestone
- eat pitted cobblestone
MyGame.settings.set({
debug: {
general: true,
},
});