-
Notifications
You must be signed in to change notification settings - Fork 9
Reference
Creates a room in the game world. Returns a reference to the room object.
-
name
- Each room must have a unique string name. This lets you refer to the room in connections from other rooms (see below). -
options
- An object containing options for the room definition:-
description
- A text description. This is what the user sees when they enter the room. -
exits
- An object literal describing the exists form this room and the rooms they connect to. Keys are the names of the exists and values are the string IDs of the connecting rooms. For example:{ north: "castle", down: "cellar", "skywards": "sky" }
-
items
- An array of items that start off in the room. Items can be picked up and carried away by players. Each item is an object containing the following fields:-
name
- A globally unique string name for the item. For example"skis"
. -
description
- A string description of the item that will be printed if the player examines it. For example"A pair of red and white skis."
-
short
- A short string description of the item that will be inserted into other text. For example"a pair of skis"
-
-
Creates a new command that the player can type in.
-
name
- The first word in the command, e.g. "look". Nodeventure will execute yourcallback
if the player types in a command starting with this word. -
helpText
(optional) - Help text to include in the output of the "help" command. -
callback
- A function that is executed when the player types in the command, arguments as follows:(rest, player, game)
-
rest
- The remainder of the command as a string. For example, if the player types "look at the room",rest
will be the string "at the room". -
player
- A reference to thePlayer
that typed in the command. Through this object you can access the player's inventory and the room they are standing in, and send text, images and commands back to the browser. -
game
- A reference to the globalGame
object. Through this object you can access all of the rooms, players, and commands in the game.
-
-
...
A variation of the command()
function that defines a command relating to a particular item in the game.
-
nameAndItem
- An array of two strings: the first word of the command and the name of the item to which the command applies. Nodeventure will execute yourcallback
if the player types in a command starting with the name and the item. -
helpText
(optional) - Help text to include in the output of the "help" command. -
callback
- A callback function that is executed when the player types in the command. See the help forcommand()
for more details.
Register a handler for an event.
-
eventName
- The name of the event. -
callback
- A function to be executed whenever the event fires. The arguments depend on the specific event.
A general purpose event that fires every second. No arguments.