setTerrainModifier: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 4: Line 4:
|version=1.5.2
|version=1.5.2
|description=
|description=
Set the Terrain Modifier for the named Token or for the Current Token if no name is given.
Set the Terrain Modifier for the named Token or for the Current Token if no name is given. To set the type of Terrain Modifier, pass a JSON Object containing the correct key:value pairs.


|usage=
|usage=
Line 10: Line 10:
setTerrainModifier(mod)
setTerrainModifier(mod)
setTerrainModifier(mod, token)
setTerrainModifier(mod, token)
setTerrainModifier(mod, token, map)
setTerrainModifier(jobj)
setTerrainModifier(jobj, token)
setTerrainModifier(jobj, token, map)
</source>
</source>
'''Parameters'''
'''Parameters'''
{{param|mod|A floating point number.}}
{{param|mod|A floating point number.}}
{{param|token|Optional token name.}}
{{param|token|Optional token name.}}
{{param|map|Optional map name.}}
{{param|jobj|A JSON object with .}}


|example=
|example=
Line 22: Line 28:
</source>
</source>
'''Returns:'''
'''Returns:'''
<source lang="mtmacro">
2.0
</source>
Set the Terrain Modifier and Type for the current token.
<source lang="mtmacro" line>
[h: jobj = '{"terrainModifier": 3.0, "terrainModifierOperation": "ADD"}']
[r: tmod = setTerrainModifier(jobj)]<br>
<pre>[r: json.indent(getTerrainModifier("JSON"),2)]</pre>
</source>
'''Returns:'''
<source lang="javascript">
3.0
{
  "terrainModifier": 3,
  "terrainModifierOperation": "ADD",
  "terrainModifiersIgnored": ["NONE"]
}
</source>
Set a token to ignore terrain modifier types: {{code|ADD}}, {{code|MULTIPLY}}
<source lang="mtmacro" line>
<source lang="mtmacro" line>
2.0
[h: jobj = '{"terrainModifiersIgnored": ["ADD","MULTIPLY"]}']
[h: setTerrainModifier(jobj)]
<pre>[r: json.indent(getTerrainModifier("JSON"),2)]</pre>
</source>
'''Returns:'''
<source lang="javascript">
{
  "terrainModifier": 0,
  "terrainModifierOperation": "NONE",
  "terrainModifiersIgnored": [
    "MULTIPLY",
    "ADD"
  ]
}
</source>
</source>


|also=
|also=

Revision as of 18:12, 17 January 2020

setTerrainModifier() Function

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

Introduced in version 1.5.2
Set the Terrain Modifier for the named Token or for the Current Token if no name is given. To set the type of Terrain Modifier, pass a JSON Object containing the correct key:value pairs.

Usage

setTerrainModifier(mod)
setTerrainModifier(mod, token)
setTerrainModifier(mod, token, map)
setTerrainModifier(jobj)
setTerrainModifier(jobj, token)
setTerrainModifier(jobj, token, map)

Parameters

  • mod - A floating point number.
  • token - Optional token name.
  • map - Optional map name.
  • jobj - A JSON object with .

Example

Set the Terrain Modifier to 2.0 for the current token.
[r: tmod = setTerrainModifier(2.0)]

Returns:

2.0

Set the Terrain Modifier and Type for the current token.

[h: jobj = '{"terrainModifier": 3.0, "terrainModifierOperation": "ADD"}']
[r: tmod = setTerrainModifier(jobj)]<br>
<pre>[r: json.indent(getTerrainModifier("JSON"),2)]</pre>

Returns:

3.0
{
  "terrainModifier": 3,
  "terrainModifierOperation": "ADD",
  "terrainModifiersIgnored": ["NONE"]
}

Set a token to ignore terrain modifier types: ADD, MULTIPLY

[h: jobj = '{"terrainModifiersIgnored": ["ADD","MULTIPLY"]}']
[h: setTerrainModifier(jobj)]
<pre>[r: json.indent(getTerrainModifier("JSON"),2)]</pre>

Returns:

{
  "terrainModifier": 0,
  "terrainModifierOperation": "NONE",
  "terrainModifiersIgnored": [
    "MULTIPLY", 
    "ADD"
  ]
}

See Also