Public Functions:Player
Properties
These specific player properties provide shortcuts to a few important pieces of player information.
- MyGame.player.inventory Returns the player's inventory. This gets a deep list that includes nested assets, so long as they are known.
-
MyGame.player.nest
If player is nested, returns the player's nest in this format:
{ in: "asset_id" }. - MyGame.player.room Returns the object of the room the player is in.
Getters
Player getter functions provide shortcuts to get useful information about the player.
-
MyGame.player.getInventory()
This method returns the player's inventory. This gets a deep list that
includes nested assets, so long as they are known. A shortcut is
available at
game.player.inventory -
MyGame.player.getKey("asset")
Object|Null
If the player is holding any keys that unlock the specified asset, this
method returns an asset object for the first key found. Returns
nullif player is not carrying any keys for the specified asset. This method only works with Entity assets. - MyGame.player.getKeys("asset") Array Since it's always possible that player may be holding multiple valid keys, this method returns an array of key asset objects, if player is holding them. Returns an empty array if player is not carrying any keys for the specified asset. This method only works with Entity assets.
-
MyGame.player.getNest()
If player is nested, returns the player's nest in this format:
{ in: "asset_id" }. There is a shortcut atgame.player.nest.
Nesting is a distinct form of parent / child relationship that only applies to the Character class and its children. Characters may be simultaneously nested in an asset while still being in a room. - MyGame.player.getNestAsset() If player is nested, returns the asset the player is nested in. Nesting is a distinct form of parent / child relationship that only applies to members of the Character class tree. Characters may be simultaneously nested in an asset while still being in a room.
-
MyGame.player.hasKey("asset")
{String}
asset a name or ID representing an
asset
Boolean
This method checks whether the player is carrying a key for the
specified asset. Returns
falseif specified asset is invalid or can't be unlocked or has not key, etc. This method only works with Entity assets. - MyGame.player.hasSeen("asset") {String} asset a name or ID representing an asset Boolean This method checks whether the player has seen the specified asset.
- MyGame.player.isNested() Boolean Returns whether the player is currently nested.
- MyGame.player.knowsAbout("asset") {String} asset a name or ID representing an asset Boolean This method checks whether the player knows about the specified asset.
-
MyGame.player.sees("asset")
{String}
asset a name or ID representing an
asset
Boolean
This method checks whether the player can see the specified asset.
Returns
falseif specified asset can't be seen for any reason, including room is dark, asset is not in room, asset is hidden inside another closed asset, etc. This method only works with Entity assets.
Misc
Player functions provide shortcuts to do things with the player.
-
MyGame.movePlayerTo("aspect",
"asset")
{String}
aspect a preposition representing an
aspect
{String}
asset a name or ID representing an
asset
MyGame.movePlayerTo("asset")
{String}
asset a name or ID representing an
asset
Boolean
This method accepts either an asset name or an aspect + asset name. If
an asset is given without an aspect, it uses the asset's default aspect.
This method moves the player to the specified aspect of asset. Returns
falseif specified asset is invalid. If the asset is a new room, calls game.setRoom() on conclusion to update the game display.