setTerrainModifier: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Created page with "{{MacroFunction |name=setTerrainModifier |trusted=false |version=1.5.2 |description= Set the Terrain Modifier for the named Token or for the Current Token if no name is given....")
 
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{MacroFunction
{{MacroFunction
|name=setTerrainModifier
|name=setTerrainModifier
|trusted=false
|trusted=true
|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=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
setTerrainModifier(mod)
setTerrainModifier(mod)
setTerrainModifier(mod, token)
setTerrainModifier(mod, token)
</source>
setTerrainModifier(mod, token, map)
setTerrainModifier(jobj)
setTerrainModifier(jobj, token)
setTerrainModifier(jobj, token, map)
</syntaxhighlight>
'''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=
Set the Terrain Modifier to 2.0 for the current token.
Set the Terrain Modifier to 2.0 for the current token.


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


|also=
|also=
{{func|getTerrainModifier}}
{{func|getTerrainModifier}}


|changes=
* '''1.5.11''' - New Terrain Modifier options.
}}
}}
[[Category:Token Function]]
[[Category:Token Function]]

Latest revision as of 20:32, 14 March 2023

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

Version Changes

  • 1.5.11 - New Terrain Modifier options.