setTerrainModifier: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
setTerrainModifier(mod) | setTerrainModifier(mod) | ||
setTerrainModifier(mod, token) | setTerrainModifier(mod, token) | ||
Line 14: | Line 14: | ||
setTerrainModifier(jobj, token) | setTerrainModifier(jobj, token) | ||
setTerrainModifier(jobj, token, map) | setTerrainModifier(jobj, token, map) | ||
</ | </syntaxhighlight> | ||
'''Parameters''' | '''Parameters''' | ||
{{param|mod|A floating point number.}} | {{param|mod|A floating point number.}} | ||
Line 24: | Line 24: | ||
Set the Terrain Modifier to 2.0 for the current token. | Set the Terrain Modifier to 2.0 for the current token. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: tmod = setTerrainModifier(2.0)] | [r: tmod = setTerrainModifier(2.0)] | ||
</ | </syntaxhighlight> | ||
'''Returns:''' | '''Returns:''' | ||
< | <syntaxhighlight lang="mtmacro"> | ||
2.0 | 2.0 | ||
</ | </syntaxhighlight> | ||
Set the Terrain Modifier and Type for the current token. | Set the Terrain Modifier and Type for the current token. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: jobj = '{"terrainModifier": 3.0, "terrainModifierOperation": "ADD"}'] | [h: jobj = '{"terrainModifier": 3.0, "terrainModifierOperation": "ADD"}'] | ||
[r: tmod = setTerrainModifier(jobj)]<br> | [r: tmod = setTerrainModifier(jobj)]<br> | ||
<pre>[r: json.indent(getTerrainModifier("JSON"),2)]</pre> | <pre>[r: json.indent(getTerrainModifier("JSON"),2)]</pre> | ||
</ | </syntaxhighlight> | ||
'''Returns:''' | '''Returns:''' | ||
< | <syntaxhighlight lang="javascript"> | ||
3.0 | 3.0 | ||
{ | { | ||
Line 47: | Line 47: | ||
"terrainModifiersIgnored": ["NONE"] | "terrainModifiersIgnored": ["NONE"] | ||
} | } | ||
</ | </syntaxhighlight> | ||
Set a token to ignore terrain modifier types: {{code|ADD}}, {{code|MULTIPLY}} | Set a token to ignore terrain modifier types: {{code|ADD}}, {{code|MULTIPLY}} | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: jobj = '{"terrainModifiersIgnored": ["ADD","MULTIPLY"]}'] | [h: jobj = '{"terrainModifiersIgnored": ["ADD","MULTIPLY"]}'] | ||
[h: setTerrainModifier(jobj)] | [h: setTerrainModifier(jobj)] | ||
<pre>[r: json.indent(getTerrainModifier("JSON"),2)]</pre> | <pre>[r: json.indent(getTerrainModifier("JSON"),2)]</pre> | ||
</ | </syntaxhighlight> | ||
'''Returns:''' | '''Returns:''' | ||
< | <syntaxhighlight lang="javascript"> | ||
{ | { | ||
"terrainModifier": 0, | "terrainModifier": 0, | ||
Line 65: | Line 65: | ||
] | ] | ||
} | } | ||
</ | </syntaxhighlight> | ||
Latest revision as of 23:59, 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.