createTokens: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page createTokens to CreateTokens without leaving a redirect: Converting page title to first-letter uppercase)
m (Conversion script moved page CreateTokens to createTokens: Converting page titles to lowercase)
(No difference)

Revision as of 23:45, 9 February 2023

 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.