getTokenImage: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Unifying Current Token red link.)
No edit summary
 
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{MacroFunction
{{MacroFunction
|name=getTokenImage
|name=getTokenImage
|description=Returns the [[Asset ID|asset id]] of the image for the for the [[Current Token]].
|description=
Returns the [[Asset ID|asset id]] of the image for the for the [[Current Token]].


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: assetId = getTokenImage(size)]
getTokenImage()
</source>
getTokenImage(size)
getTokenImage(size, tokenRef)
getTokenImage(size, tokenRef, mapname)
</syntaxhighlight>


|example=
'''Parameters'''
{{param|size|OPTIONAL: The size in pixels the image should be returned as. If a blank string "", no size adjustment is done. Defaults to "".}}
{{param|tokenRef|OPTIONAL: Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token for which you want to retrieve the token image, defaults to the [[Current Token]]. }}
{{param|mapname|OPTIONAL: The name of the map to find the token.  Defaults to the current map.}}
{{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.}}
 
|examples=
To display the image for the current [[Token:token|token]].
To display the image for the current [[Token:token|token]].
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
<img src='[r:getTokenImage()]'></img>
<img src='[r:getTokenImage()]'></img>
</source>
</syntaxhighlight>
 
To get the image of any [[Token:token|token]] using its id and the token roll option.
<syntaxhighlight lang="mtmacro" line>
[h, token(tokenId): imgAsset = getTokenImage()]
</syntaxhighlight>
|changes={{change|1.5.4|Added {{code|id}} and {{code|mapname}} parameter options.}}
|also=
[[getImage|getImage]], [[getTokenHandout|getTokenHandout]], [[getTokenPortrait|getTokenPortrait]]
}}
}}
[[Category:Token Function]]
[[Category:Token Function]]

Latest revision as of 21:46, 9 May 2024

getTokenImage() Function

Returns the asset id of the image for the for the Current Token.

Usage

getTokenImage()
getTokenImage(size)
getTokenImage(size, tokenRef)
getTokenImage(size, tokenRef, mapname)

Parameters

  • size - OPTIONAL: The size in pixels the image should be returned as. If a blank string "", no size adjustment is done. Defaults to "".
  • tokenRef - OPTIONAL: Either the token id or Token Name of the token for which you want to retrieve the token image, defaults to the Current Token.
  • mapname - OPTIONAL: The name of the map to find the token. Defaults to the current map.
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.

Examples

To display the image for the current token.
<img src='[r:getTokenImage()]'></img>

To get the image of any token using its id and the token roll option.

[h, token(tokenId): imgAsset = getTokenImage()]

See Also

Version Changes

  • 1.5.4 - Added id and mapname parameter options.