createTokens: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Created page with "{{MacroFunction |name=createTokens |proposed=true |trusted=false |version=1.11.0 |description= Creates a token from the information in the required JSON array parameter. One t...")
 
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{MacroFunction
{{MacroFunction
|name=createTokens
|name=createTokens
|proposed=true
|trusted=false
|trusted=false
|version=1.11.0
|version=1.11.0

Latest revision as of 16:43, 29 August 2024

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.