-
Notifications
You must be signed in to change notification settings - Fork 9
Reference
Creates a room in the game world. Returns a reference to a Room
object.
-
name
- Each room must have a unique string name. This lets you refer to the room in the definitions of other rooms and items (see below). -
options
- An object containing options for the room definition:-
description
- A string description. Nodeventure prints this when the player enters the room. -
exits
- An object literal describing the exits from this room and the rooms they connect to. Keys are the names of the exits and values are the string IDs of the connecting rooms. For example:{ north: "castle", down: "cellar", "skywards": "sky" }
-
Creates an item in a room. Returns a reference to an Item
object.
-
roomName
- The name of the room to which to add the items. -
itemName
- A string name for the item that differentiates it from other items in the room. -
respawnTime
- If an item is taken by a player, Nodeventure eventually spawns a replacement for other people to pick up. This is the number of milliseconds to wait until a new item is created. -
descriptions
- An object containing short and long descriptions of the item. For example:{ description: "A nice pair of red and white skis.", short: "a pair of skis" }
The
description
is used whenever a paragraph of text is needed to describe the item. Theshort
description is used to refer to the item mid-sentence.
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:callback(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. Returns void
.
-
name
- The first word in the command, e.g. "use". Nodeventure will execute yourcallback
if the player types in a command starting withname
anditemName
. -
itemName
- The second word in the command, e.g. "skis". Nodeventure will execute yourcallback
if the player types in a command starting withname
anditemName
. -
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. Arguments are as follows:callback(rest, player, item, game)
-
rest
- The remainder of the command as a string. -
player
- A reference to thePlayer
that typed in the command. -
item
- A reference to the item used. -
game
- A reference to the globalGame
object.
-
Register a handler for an event. Returns void
.
-
eventName
- The name of the event. -
callback
- A function to be executed whenever the event fires. The arguments depend on the specific event.
Create a character. For example, a yeti. Returns a reference to a Character object.
-
name
- A globally unique string name for the character. -
options
- An options object containing the following fields:-
location
- The name of the room that the character starts in. -
description
- A description of the character.
-
Use the handler()
function and the tick
event to give the character behaviour.
Arguments: [ player, message ]
A general purpose event that fires every second. No arguments.
Arguments: [ player, room, game ]
Arguments: [ player, room, game ]
Arguments: [ rest, player, game ]