getTerrainModifier: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Text replacement - "source>" to "syntaxhighlight>")
m (Text replacement - "<source" to "<syntaxhighlight")
Line 7: Line 7:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
getTerrainModifier()
getTerrainModifier()
getTerrainModifier(token)
getTerrainModifier(token)
Line 23: Line 23:
Get the Terrain Modifier for the named token:
Get the Terrain Modifier for the named token:


<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: tmod = getTerrainModifier("Sticky Floor Tile")]
[r: tmod = getTerrainModifier("Sticky Floor Tile")]
</syntaxhighlight>
</syntaxhighlight>


'''Output:'''
'''Output:'''
<source lang="mtmacro">
<syntaxhighlight lang="mtmacro">
2.0
2.0
</syntaxhighlight>
</syntaxhighlight>


Get terrain modifiers as a JSON Object on the Wizard's Keep map.
Get terrain modifiers as a JSON Object on the Wizard's Keep map.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: tmod = getTerrainModifier("JSON", "Sticky Floor Tile", "Wizard's Keep")]
[r: tmod = getTerrainModifier("JSON", "Sticky Floor Tile", "Wizard's Keep")]
</syntaxhighlight>
</syntaxhighlight>


'''Output:'''
'''Output:'''
<source lang="javascript">
<syntaxhighlight lang="javascript">
{
{
     "terrainModifier": 2.0,
     "terrainModifier": 2.0,
Line 47: Line 47:


Get terrain modifiers for the named token that ignores ADD & MULTIPLY mod types.
Get terrain modifiers for the named token that ignores ADD & MULTIPLY mod types.
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[r: tmod = getTerrainModifier("Elf with Fancy Feet")]
[r: tmod = getTerrainModifier("Elf with Fancy Feet")]
</syntaxhighlight>
</syntaxhighlight>


'''Output:'''
'''Output:'''
<source lang="javascript">
<syntaxhighlight lang="javascript">
{
{
     "terrainModifier": 0.0,
     "terrainModifier": 0.0,

Revision as of 20:29, 14 March 2023

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(token)
getTerrainModifier(token, map)
getTerrainModifier(type)
getTerrainModifier(type, token)
getTerrainModifier(type, token, map)

Parameters

  • token - Optional token name or return type.
  • 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.

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.