createTokens

From RPTools Wiki
Revision as of 22:39, 9 February 2023 by Conversion script (talk | contribs) (Conversion script moved page createTokens to CreateTokens without leaving a redirect: Converting page title to first-letter uppercase)
Jump to navigation Jump to search

 Note: This refers to a proposed change that has not been implemented in the main code base yet.

createTokens() Function

Introduced in version 1.11.0
Creates a token from the information in the required JSON array parameter. One token is created for each JSON object in the array. Each JSON object must have name and tokenImage key/value pairs.

Usage

createTokens(param1)

Parameters

  • param1 - An array of JSON objects as described for the updates parameter of copyToken().

Example

Create two tokens using an existing token image with random X/Y location.
[h: tok1 = json.set("{}", "tokenImage", getImage("Hero"), "name", "Hero 1","x",1d10,"y",1d10)] 
[h: tok2 = json.set("{}", "tokenImage", getImage("Hero"), "name", "Hero 2","x",1d10,"y",1d10)] 
[h: toks = json.append("[]", tok1, tok2)]  
[r: ids = createTokens(toks)]

Returns:

A JSON array with the IDs of the created tokens.

See Also

Version Changes

  • 1.11.0 - First released.