Public Functions:Overview
Technically, all AdventureJS functions are public functions, because AdventureJS has no private functions. However, the functions listed in this section have been surfaced specifically for authors to use. Some of these functions are uniquely for authors; some are convenient aliases to deeper internal functions; others are slight variations on internal functions. All of them have been chosen with new authors in mind, and you will find it useful to begin here. Though you are welcome to use any functions you find in the framework code, you may find things a little less intuitive once you move beyond these functions.
- Display functions provide shortcuts to clear the player's input and/or the display output, print a list of exits from the current room, toggle the visibility of the game's statusbar.
- Game functions provide shortcuts to methods scoped to the top level game object.
- Game getter functions provide shortcuts to methods for getting the player, the current room, a list of exits from the current room, the current room object.
- Player getter functions provide shortcuts to player methods such as getting player inventory, and to states such as whether the player can see a specified asset, whether the player has a key to unlock a specified asset, whether and where the player is nested.
- Room getter functions provide shortcuts to room methods such as getting a list of the current room's exits or usable directions.
- The get asset function (not to be confused with asset getter functions) is a special utility function for getting any game asset by name or ID.
- Asset getter functions (not to be confused with the get asset function) provide shortcuts for getting certain properties of Tangible classed assets such as a list of contents, the parent container, and the room an asset is in.
- Asset.$is() is a special utility function for getting numerous asset properties, a sort of Swiss knife of asset functions.
- Asset.isAspect functions are specific shortcuts to test whether one asset is in, on, under, behind, or attached to another asset.
- Asset placement functions provide methods to move assets into or out of other assets.
- Asset verb functions provide shortcuts to get information about whether a specified verb has been attempted on or applied to a specified asset, how many times the verb has been attempted or applied to the asset, whether an asset has particular verb quirks.
- World variable functions provide shortcuts to getting, setting, incrementing, and decrementing world variables, which are variables that get saved with the world state so they are subject to save, restore, and undo operations.
- Interval functions provide shortcuts to managing intervals, which are functions that get called every turn, such as water pouring from a faucet, or a guard checking a gate, or an ant moving a sugarcube a bit on every turn.
- Utility functions are different from other public functions in that they are scoped to the AdventureJS object rather than the game. They include simple methods for things like changing text case, finding common elements in multiple arrays, getting distance between two points, checking whether a value is false or null, picking a random item from an array, and more.