Difference between revisions of "Mod:Function/Roll20 object"
From Roll20 Wiki
(→Roll20 object functions) |
m (→Roll20 object functions) |
||
Line 26: | Line 26: | ||
|- | |- | ||
| | | | ||
− | | <code>[[#get | + | | <code>[[#get %5BAsynchronous%5D|get]]</code> |
| Gets the value of "notes", "gmnotes", or "bio" properties of a character or handout Roll20 object. | | Gets the value of "notes", "gmnotes", or "bio" properties of a character or handout Roll20 object. | ||
|- | |- |
Revision as of 08:05, 29 July 2016
Roll20 objects are a special kind of JavaScript object. They represent something in your campaign, such as a token on the tabletop or a character in the journal, and there is some special consideration for using them. Extended Syntax Roll20 Objects is an API script which modifies how you can interact with Roll20 objects.
Contents |
Roll20 object fields
Property | Description |
---|---|
id
|
This property is shorthand for obj.get('id') .
|
id
This field is shorthand for obj.get('id')
. All Roll20 objects have a _id
property which uniquely identifies them within a campaign, but their properties are not directly accessible. Normally you have you call get
in order to get the value of a property, but because _id
is needed on such a frequent basis, this shim filed is provided for convenience.
Roll20 object functions
Return type | Function | Description |
---|---|---|
varies | get
|
Gets the value of a specified property. |
get
|
Gets the value of "notes", "gmnotes", or "bio" properties of a character or handout Roll20 object. | |
remove
|
Deletes the Roll20 object. | |
set
|
Sets one or more specified property values. |
get
Parameters
- parameter
- (String) The name of the parameter to get. If you are getting the value of a read-only property (one which starts with an underscore, like
_id
or_type
), the leading underscore is not required.
Returns
The value of the specified property
Examples
var character = getMyCharacter(), strength = findObjs({ type: 'attribute', characterid: character.id, name: 'strength' })[0]; log(strength.get('current'));
get
Asynchronous
This version of get
will be automatically called if parameter is "notes", "gmnotes", or "bio" and the Roll20 object is a character or handout.
Parameters
- parameter
- (String) The name of the parameter to get. If you are getting the value of a read-only property (one which starts with an underscore, like
_id
or_type
), the leading underscore is not required. - callback
- (Function) A callback function which will receive the value of the property as a parameter.
Returns
(Void)
Examples
var character = getMyCharacter(); character.get('bio', function(text) { log(text); });