getTerrainModifier: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{MacroFunction |name=getTerrainModifier |trusted=false |version=1.5.2 |description= Gets the Terrain Modifier for the named Token or for the Current Token if no name is given...") |
No edit summary |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name=getTerrainModifier | |name=getTerrainModifier | ||
|trusted= | |trusted=true | ||
|version=1.5.2 | |version=1.5.2 | ||
|description= | |description= | ||
Gets the Terrain Modifier for the named Token or for the Current Token if no name is given. | Gets the Terrain Modifier for the named Token or for the Current Token if no name is given. If the first parameter is {{code|"JSON"}} then a JSON Object is returned with the Terrain Modifier, Terrain Modifier Type and an array of Ignored Terrain Modifier Types. | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
getTerrainModifier() | getTerrainModifier() | ||
getTerrainModifier(token) | getTerrainModifier(tokenRef) | ||
</ | getTerrainModifier(tokenRef, map) | ||
getTerrainModifier(type) | |||
getTerrainModifier(type, token) | |||
getTerrainModifier(type, tokenRef, map) | |||
</syntaxhighlight> | |||
'''Parameters''' | '''Parameters''' | ||
{{param|token|Optional token name.}} | {{param|tokenRef|Optional Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token.}} | ||
{{param|type|First parameter can be the string "JSON" to get a JSON Object back.}} | |||
{{param|map|Optional map name to find the token on. Current map is used if not supplied.}} | |||
{{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.}} | |||
|example= | |example= | ||
Get the Terrain Modifier for the named token: | Get the Terrain Modifier for the named token: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: tmod = getTerrainModifier("Sticky Floor Tile")] | [r: tmod = getTerrainModifier("Sticky Floor Tile")] | ||
</ | </syntaxhighlight> | ||
'''Output:''' | '''Output:''' | ||
< | <syntaxhighlight lang="mtmacro"> | ||
2.0 | 2.0 | ||
</ | </syntaxhighlight> | ||
Get terrain modifiers as a JSON Object on the Wizard's Keep map. | |||
<syntaxhighlight lang="mtmacro" line> | |||
[r: tmod = getTerrainModifier("JSON", "Sticky Floor Tile", "Wizard's Keep")] | |||
</syntaxhighlight> | |||
'''Output:''' | |||
<syntaxhighlight lang="javascript"> | |||
{ | |||
"terrainModifier": 2.0, | |||
"terrainModifierOperation": "ADD", | |||
"terrainModifiersIgnored": ["NONE"] | |||
} | |||
</syntaxhighlight> | |||
Get terrain modifiers for the named token that ignores ADD & MULTIPLY mod types. | |||
<syntaxhighlight lang="mtmacro" line> | |||
[r: tmod = getTerrainModifier("Elf with Fancy Feet")] | |||
</syntaxhighlight> | |||
'''Output:''' | |||
<syntaxhighlight lang="javascript"> | |||
{ | |||
"terrainModifier": 0.0, | |||
"terrainModifierOperation": "NONE", | |||
"terrainModifiersIgnored": ["ADD","MULTIPLY"] | |||
} | |||
</syntaxhighlight> | |||
|also= | |also= | ||
{{func|setTerrainModifier}} | {{func|setTerrainModifier}} | ||
|changes= | |||
* '''1.5.11''' - Added support for new terrain modifier types. | |||
}} | }} | ||
[[Category:Token Function]] | [[Category:Token Function]] |
Latest revision as of 23:59, 14 May 2024
getTerrainModifier() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.5.2
Gets the Terrain Modifier for the named Token or for the Current Token if no name is given. If the first parameter is
"JSON"
then a JSON Object is returned with the Terrain Modifier, Terrain Modifier Type and an array of Ignored Terrain Modifier Types.Usage
getTerrainModifier()
getTerrainModifier(tokenRef)
getTerrainModifier(tokenRef, map)
getTerrainModifier(type)
getTerrainModifier(type, token)
getTerrainModifier(type, tokenRef, map)
Parameters
tokenRef
- Optional Either the tokenid
or Token Name of the token.type
- First parameter can be the string "JSON" to get a JSON Object back.map
- Optional map name to find the token on. Current map is used if not supplied.
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.
Example
Get the Terrain Modifier for the named token:
[r: tmod = getTerrainModifier("Sticky Floor Tile")]
Output:
2.0
Get terrain modifiers as a JSON Object on the Wizard's Keep map.
[r: tmod = getTerrainModifier("JSON", "Sticky Floor Tile", "Wizard's Keep")]
Output:
{
"terrainModifier": 2.0,
"terrainModifierOperation": "ADD",
"terrainModifiersIgnored": ["NONE"]
}
Get terrain modifiers for the named token that ignores ADD & MULTIPLY mod types.
[r: tmod = getTerrainModifier("Elf with Fancy Feet")]
Output:
{
"terrainModifier": 0.0,
"terrainModifierOperation": "NONE",
"terrainModifiersIgnored": ["ADD","MULTIPLY"]
}
See Also
Version Changes
- 1.5.11 - Added support for new terrain modifier types.