setTokenLayoutProps: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Created page with "{{MacroFunction |name=setTokenLayoutProps |version=1.6.1 |description= Se the token layout scale, xOffset, and yOffset. |usage= <source lang="mtmacro" line> setTokenLayoutPro...")
 
No edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 2: Line 2:
|name=setTokenLayoutProps
|name=setTokenLayoutProps
|version=1.6.1
|version=1.6.1
|description= Se the token layout scale, xOffset, and yOffset.
|description= Set the Token Layout {{code|scale}}, {{code|xOffset}}, and {{code|yOffset}} values. These values will be reflected in the positioning and size of the token image within the Layout portion of the Config tab in the Edit Token Dialog as well as on the map.
 
|usage=  
|usage=  
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
setTokenLayoutProps(scale, xOffset, yOffset)
setTokenLayoutProps(scale, xOffset, yOffset)
setTokenLayoutProps(scale, xOffset, yOffset, id)
setTokenLayoutProps(scale, xOffset, yOffset, id)
setTokenLayoutProps(scale, xOffset, yOffset, id, mapName)
setTokenLayoutProps(scale, xOffset, yOffset, id, mapRef)
</source>
</syntaxhighlight>


'''Parameters'''
'''Parameters'''
{{param|scale|The scale of the token layout.}}
{{param|scale|The scale of the token layout. If an empty string, the scale is not changed.}}
{{param|xOffset|The xOffset of the token layout.}}
{{param|xOffset|The xOffset of the token layout. If an empty string, the xOffset is not changed. Negative values shift the image left.}}
{{param|yOffset|The yOffset of the token layout.}}
{{param|yOffset|The yOffset of the token layout. If an empty string, the yOffset is not changed. Negative values shift the image up.}}
{{param|tokenID|The token {{code|id}} of the token to name, defaults to the [[Current Token]]. {{TrustedParameter}}}}
{{param|id|The token {{code|id}} of the token to name, defaults to the [[Current Token]]. {{TrustedParameter}}}}
{{param|mapname|The name of the map to find the token.  Defaults to the current map.}}
{{param|mapRef|The Name or ID of the map to find the token.  Defaults to the current map.}}
The {{code|xOffset}} and {{code|yOffset}} values must be integers.
 
|example=
Set the layout properties of the Frog token to make it 50% larger and moved up 24 pixels, leaving the xOffset as it is. Then read them back.
<syntaxhighlight lang="mtmacro" line>
[h: setTokenLayoutProps(1.5,"",-24,"Frog")]
[r: getTokenLayourProps("json","Frog")]
</syntaxhighlight>
'''Returns:'''
<syntaxhighlight lang="javascript">
{"scale":1.5,"xOffset":4.0,"yOffset":-24.0}
</syntaxhighlight>
|also=
{{func|getTokenLayoutProps}}


}}
}}
[[Category:Token Function]]
[[Category:Token Function]]

Latest revision as of 23:59, 14 March 2023

setTokenLayoutProps() Function

Introduced in version 1.6.1
Set the Token Layout scale, xOffset, and yOffset values. These values will be reflected in the positioning and size of the token image within the Layout portion of the Config tab in the Edit Token Dialog as well as on the map.

Usage

setTokenLayoutProps(scale, xOffset, yOffset)
setTokenLayoutProps(scale, xOffset, yOffset, id)
setTokenLayoutProps(scale, xOffset, yOffset, id, mapRef)

Parameters

  • scale - The scale of the token layout. If an empty string, the scale is not changed.
  • xOffset - The xOffset of the token layout. If an empty string, the xOffset is not changed. Negative values shift the image left.
  • yOffset - The yOffset of the token layout. If an empty string, the yOffset is not changed. Negative values shift the image up.
  • id - The token id of the token to name, defaults to the Current Token.

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

  • mapRef - The Name or ID of the map to find the token. Defaults to the current map.

The xOffset and yOffset values must be integers.

Example

Set the layout properties of the Frog token to make it 50% larger and moved up 24 pixels, leaving the xOffset as it is. Then read them back.
[h: setTokenLayoutProps(1.5,"",-24,"Frog")]
[r: getTokenLayourProps("json","Frog")]

Returns:

{"scale":1.5,"xOffset":4.0,"yOffset":-24.0}

See Also