setTerrainModifier: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page setTerrainModifier to SetTerrainModifier without leaving a redirect: Converting page title to first-letter uppercase)
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 7: Line 7:


|usage=
|usage=
<source lang="mtmacro" line>
<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)
</source>
</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.


<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">
<syntaxhighlight lang="mtmacro">
2.0
2.0
</source>
</syntaxhighlight>


Set the Terrain Modifier and Type for the current token.
Set the Terrain Modifier and Type for the current token.


<source lang="mtmacro" line>
<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>
</source>
</syntaxhighlight>
'''Returns:'''
'''Returns:'''
<source lang="javascript">
<syntaxhighlight lang="javascript">
3.0
3.0
{
{
Line 47: Line 47:
   "terrainModifiersIgnored": ["NONE"]
   "terrainModifiersIgnored": ["NONE"]
}
}
</source>
</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}}
<source lang="mtmacro" line>
<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>
</source>
</syntaxhighlight>
'''Returns:'''
'''Returns:'''
<source lang="javascript">
<syntaxhighlight lang="javascript">
{
{
   "terrainModifier": 0,
   "terrainModifier": 0,
Line 65: Line 65:
   ]
   ]
}
}
</source>
</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.