Room()

new Room()

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 }

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

Extends

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

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

findExit(exitName) → {false|Object}

Get the exit definition of a room's exit by searching the exit name

Parameters:
Name Type Description
exitName string

exit name search

Returns:
false | Object

getBroadcastTargets() → {Array.<Character>}

Used by Broadcaster

Returns:
Array.<Character>

getDoor(fromRoom) → {Object}

Parameters:
Name Type Description
fromRoom Room
Returns:
Object

getExits() → {Array.<{id: string, direction: string, inferred: boolean, room: Room=}>}

Get exits for a room. Both inferred from coordinates and defined in the 'exits' property.

Returns:
Array.<{id: string, direction: string, inferred: boolean, room: Room=}>

getExitToRoom(nextRoom) → {false|Object}

Get the exit definition of a room's exit to a given room

Parameters:
Name Type Description
nextRoom Room
Returns:
false | Object

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

openDoor(fromRoom)

Parameters:
Name Type Description
fromRoom Room

removeItem(item)

Parameters:
Name Type Description
item Item

removeNpc(npc, removeSpawn)

Parameters:
Name Type Default Description
npc Npc
removeSpawn boolean false

removePlayer(player)

Parameters:
Name Type Description
player Player

spawnItem(state, entityRef) → {Item}

Parameters:
Name Type Description
state GameState
entityRef string
Returns:
Item -

The newly created item

spawnNpc(state, entityRef) → {Npc}

Parameters:
Name Type Description
state GameState
entityRef string
Fires:
Returns:
Npc

unlockDoor(fromRoom)

Parameters:
Name Type Description
fromRoom Room

Events

channelReceive

Docs limit this to be for GameEntity (Area/Room/Item) but also applies to NPC and Player

Parameters:
Name Type Description
channel Channel
sender Character
rawMessage string
Inherited From:

npcEnter

Parameters:
Name Type Description
npc Npc
prevRoom Room

npcLeave

Parameters:
Name Type Description
npc Npc
nextRoom Room

playerEnter

Parameters:
Name Type Description
player Player
prevRoom Room

playerLeave

Parameters:
Name Type Description
player Player
nextRoom Room

ready

Fires after the room is hydrated and added to its area

spawn

Fires when the room is created but before it has hydrated its default contents. Use the ready event if you need default items to be there.

updateTick

See: