Room

new Room()

Listens to Events:
  • Room#event:updateTick
Properties:
Name Type Attributes Description
area Area

Area room is in

coordinates Object <optional>

Defined in yml with array [x, y, z]. Retrieved with coordinates.x, coordinates.y, ...

defaultItems Array.<number>

Default list of item ids that should load in this room

defaultNpcs Array.<number>

Default list of npc ids that should load in this room

description string

Room description seen on 'look'

exits Array.<object>

Exits out of this room { id: number, direction: string, leaveMessage: string }

id number

Area-relative id (vnum)

items Set

Items currently in the room

npcs Set

Npcs currently in the room

players Set

Players currently in the room

script string

Name of custom script attached to this room

title string

Title shown on look/scan

doors object

Doors restricting access to this room. See documentation for format

Mixes In:

Extends

  • EventEmitter

Members

spawnedNpcs

spawnedNpcs keeps track of NPCs even when they leave the room for the purposes of respawn. So if we spawn NPC A into the room and it walks away we don't want to respawn the NPC until it's killed or otherwise removed from the area

Methods

addItem(item)

Parameters:
Name Type Description
item Item

addNpc(npc)

Parameters:
Name Type Description
npc Npc

addPlayer(player)

Parameters:
Name Type Description
player Player

closeDoor(fromRoom)

Parameters:
Name Type Description
fromRoom Room
Fires:
Throws:

DoorLockedError

emit(eventName, …args) → {void}

Emits event on self and proxies certain events to other entities in the room.

Parameters:
Name Type Attributes Description
eventName string
args * <repeatable>
Returns:
void

getBehavior(name) → {*}

Parameters:
Name Type Description
name string
Returns:
*

getBroadcastTargets() → {Array.<Character>}

Used by Broadcaster

Returns:
Array.<Character>

getDoor(fromRoom) → {Object}

Parameters:
Name Type Description
fromRoom Room
Returns:
Object

hasBehavior(name) → {boolean}

Parameters:
Name Type Description
name string
Returns:
boolean

hasDoor(fromRoom) → {boolean}

Check to see if this room has a door preventing movement from fromRoom to here

Parameters:
Name Type Description
fromRoom Room
Returns:
boolean

isDoorLocked(fromRoom) → {boolean}

Check to see of the door for fromRoom is locked

Parameters:
Name Type Description
fromRoom Room
Returns:
boolean

lockDoor(fromRoom)

Parameters:
Name Type Description
fromRoom Room
Fires:

openDoor(fromRoom)

Parameters:
Name Type Description
fromRoom Room
Fires:

removeItem(item)

Parameters:
Name Type Description
item Item

removeNpc(npc)

Parameters:
Name Type Description
npc Npc

removePlayer(player)

Parameters:
Name Type Description
player Player

removeSpawnedNpc(npc)

Parameters:
Name Type Description
npc Npc

respawnTick(state)

Parameters:
Name Type Description
state GameState

spawnItem(state, entityRef)

Parameters:
Name Type Description
state GameState
entityRef string

spawnNpc(state, entityRef)

Parameters:
Name Type Description
state GameState
entityRef string
Fires:

unlockDoor(fromRoom)

Parameters:
Name Type Description
fromRoom Room
Fires:

Events

doorClosed

Parameters:
Name Type Description
fromRoom Room
door object

doorOpened

Parameters:
Name Type Description
fromRoom Room
door object

doorUnlocked

Parameters:
Name Type Description
fromRoom Room
door object

doorUnlocked

Parameters:
Name Type Description
fromRoom Room
door object