herolab.getImage: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page herolab.getImage to Herolab.getImage without leaving a redirect: Converting page title to first-letter uppercase)
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
herolab.getImage(index)
herolab.getImage(index)
herolab.getImage(index, id)
herolab.getImage(index, tokenRef)
</source>
</syntaxhighlight>


'''Parameters'''
'''Parameters'''
{{param|index|The index of the image you wish to retrieve.}}
{{param|index|The index of the image you wish to retrieve.}}
{{param|id|The token id of the token to name, defaults to the Current Token.}}
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token to name, defaults to the Current Token.}}
{{Note|Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.}}


Hero Lab can store 0 to n images for a given character. The index is the order Hero Lab stores the images (not the display order in Hero lab). Index always starts at 0.
Hero Lab can store 0 to n images for a given character. The index is the order Hero Lab stores the images (not the display order in Hero lab). Index always starts at 0.
Line 20: Line 21:
|example=
|example=
Get an image asset ID from an image in a Hero Lab file and use that to set a token portrait image.
Get an image asset ID from an image in a Hero Lab file and use that to set a token portrait image.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[portraitImage = herolab.getImage(0)]
[portraitImage = herolab.getImage(0)]
[setTokenImage(portraitImage)]
[setTokenImage(portraitImage)]
</source>
</syntaxhighlight>
Returns:
Returns:
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
Asset ID of requested image.
Asset ID of requested image.
</source>
</syntaxhighlight>


|also=
|also=

Latest revision as of 23:59, 17 May 2024

herolab.getImage() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.5
Returns the asset id of the image retrieved from a Hero Lab file for a Token.

Usage

herolab.getImage(index)
herolab.getImage(index, tokenRef)

Parameters

  • index - The index of the image you wish to retrieve.
  • tokenRef - Either the token id or Token Name of the token to name, defaults to the Current Token.
Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.


Hero Lab can store 0 to n images for a given character. The index is the order Hero Lab stores the images (not the display order in Hero lab). Index always starts at 0.

Example

Get an image asset ID from an image in a Hero Lab file and use that to set a token portrait image.
[portraitImage = herolab.getImage(0)]
[setTokenImage(portraitImage)]

Returns:

Asset ID of requested image.

See Also

Version Changes

  • 1.5 - Added to main MapTool build.