Mod:Function
From Roll20 Wiki
Roll20 makes a number of functions available that are not part of core JavaScript or some other library.
Global variables
Variable | Description |
---|---|
_
|
This is the namespace object for the Underscore.js library. |
state
|
Properties of the state object will persist between game sessions. |
_
(Underscore)
This is the namespace object for the Underscore.js library. Underscore has many functions for collection manipulation.
state
Properties of the state object will persist between game sessions. The same state object is also shared between all API scripts in a campaign, so it is strongly recommended that when writing values to state, you minimize your footprint as much as possible in order to avoid name collisions. Note: state gets serialized with JSON, so you cannot store functions or objects with cyclical references.
Global functions
Return type | Function | Description |
---|---|---|
Roll20 object | Campaign
|
Gets the singleton Campaign Roll20 object. |
Roll20 object | createObj
|
Creates a new Roll20 object. |
Array of Roll20 objects | filterObjs
|
Gets all Roll20 objects which pass a predicate test. |
Array of Roll20 objects | findObjs
|
Gets all Roll20 objects with properties that match a given set of attributes. |
Array of Roll20 objects | getAllObjs
|
Gets all Roll20 objects in the campaign. |
varies | getAttrByName
|
Gets the current or max value of an attribute Roll20 object. |
Roll20 object | getObj
|
Gets a specific Roll20 object. |
log
|
Logs a message to the API console. | |
on
|
Registers an event handler. | |
Boolean | playerIsGM
|
Checks whether a player currently has GM privileges. |
playJukeboxPlaylist
|
Start playing a jukebox playlist. | |
Number | randomInteger
|
Generates a random integer value. |
sendChat
|
Sends a chat message. | |
sendPing
|
Sends a ping similar to holding the left mouse button. | |
spawnFx
|
Spawns a particle emitter. | |
spawnFxBetweenPoints
|
Spawns a particle emitter that moves from one point to another. | |
spawnWithDefinition
|
Spawns a particle emitter that is not represented by an FX Roll20 object. | |
stopJukeboxPlaylist
|
Stops all currently playing jukebox playlits. | |
toBack
|
Moves a graphic Roll20 object below all of the other graphics on the same tabletop layer. | |
toFront
|
Moves a graphic Roll20 object above all of the other graphics on the same tabletop layer. |