setTokenImage: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function setTokenImage== Sets the image for the for the Current Token. The image can come from several sources. It can come from a function that returns an [[ass...)
 
No edit summary
 
(10 intermediate revisions by 5 users not shown)
Line 1: Line 1:
==Function setTokenImage==
{{MacroFunction
|name=setTokenImage
|version=1.3b48
|description=
Sets the image for the for the [[Current Token]].  The function accepts an [[Asset ID]] or an [[Image_Token|Image Token]] name. You can get [[Asset ID]]s from macro functions such as {{func|tblImage}} or {{func|getTokenImage}}. [[Image Token]]s are special tokens whose name starts with "image:".


Sets the image for the for the [[Token:Current Token|Current Token]]. The image can come from several sources. It can come from a function that returns an [[asset id]] such as [[Macros:Functions:tblImage |tblImage()]] or [[Macros:Functions:getTokenImage|getTokenImage()]]. Or it could come from a [[Token:Image Token|Image Token]].
|usage=
<syntaxhighlight lang="mtmacro" line>
setTokenImage(assetId)
setTokenImage(assetId, id)
setTokenImage(assetId, id, mapname)
</syntaxhighlight>
<syntaxhighlight lang="mtmacro" line>
setTokenImage(imageToken)
setTokenImage(imageToken, id)
setTokenImage(imageToken, id, mapname)
</syntaxhighlight>
'''Parameters'''
{{param|assetId|The Asset ID for an image.}}
{{param|imageToken|The name of an image token e.g. "image:myimage"}}
{{param|id|OPTIONAL: The token {{code|id}} of the token for which you want to set the image, defaults to the [[Current Token]]. }}
{{param|mapname|OPTIONAL: The name of the map to find the token. Defaults to the current map.}}


===Usage===
|example=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: = setTokenImage(assetId)]
[h: = setTokenImage(tokenImageName)]
</source>
 
 
===Examples===
<source lang="mtmacro" line>
[h: setTokenImage(tblImage("elfImages", 1))]
[h: setTokenImage(tblImage("elfImages", 1))]
[h: setTokenImage("image:Elf-Dead")]
[h: setTokenImage("image:Elf-Dead")]
</source>
</syntaxhighlight>
|changes={{change|1.5.4|Added {{code|id}} and {{code|mapname}} parameter options.}}
}}
[[Category:Token Function]]

Latest revision as of 20:30, 14 March 2023

setTokenImage() Function

Introduced in version 1.3b48
Sets the image for the for the Current Token. The function accepts an Asset ID or an Image Token name. You can get Asset IDs from macro functions such as tblImage() or getTokenImage(). Image Tokens are special tokens whose name starts with "image:".

Usage

setTokenImage(assetId)
setTokenImage(assetId, id)
setTokenImage(assetId, id, mapname)
setTokenImage(imageToken)
setTokenImage(imageToken, id)
setTokenImage(imageToken, id, mapname)

Parameters

  • assetId - The Asset ID for an image.
  • imageToken - The name of an image token e.g. "image:myimage"
  • id - OPTIONAL: The token id of the token for which you want to set the image, defaults to the Current Token.
  • mapname - OPTIONAL: The name of the map to find the token. Defaults to the current map.

Example

[h: setTokenImage(tblImage("elfImages", 1))]
[h: setTokenImage("image:Elf-Dead")]


Version Changes

  • 1.5.4 - Added id and mapname parameter options.