setTokenHillVBL: Difference between revisions
(Created stub for setTokenHillVBL function) |
m (Added description; fleshed out the rest of the page) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
{{MacroFunction | {{MacroFunction | ||
|name=setTokenHillVBL | |name=setTokenHillVBL | ||
|proposed=false | |||
|trusted=true | |||
|version=1.12 | |version=1.12 | ||
|description= | |description=Sets the Hill VBL of a token to that given in the JSON object parameter. | ||
|usage= | |usage= | ||
<syntaxhighlight lang="mtmacro" line> | <syntaxhighlight lang="mtmacro" line> | ||
setTokenHillVBL(jsonarray) | |||
setTokenHillVBL(jsonarray, id) | setTokenHillVBL(jsonarray, id) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
This function is used to attach the Hill VBL passed in as a JSON object to a token. The JSON object may be be created by calling {{func|getTokenVBL}} (or similar) on a different token, and may also be used with any of the {{func|drawVBL}} or {{func|eraseVBL}} functions. | |||
Token VBL of any kind moves with the token, can be set under the VBL tab on the Token Editor Dialog and is colored YELLOW. Normal VBL is static, can be created with the VBL drawing tools or with the use of the VBL functions, and is colored BLUE. | |||
The {{code|method}} parameter in the JSON object must use one of the following (a link is provided for descriptions of each): | |||
* {{code|DOUGLAS_PEUCKER_SIMPLIFIER}} (see [https://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm Wikipedia]), | |||
* {{code|TOPOLOGY_PRESERVING_SIMPLIFIER}} (see [https://javadocng.mobanisto.com/jts-1.17.1/org/locationtech/jts/simplify/TopologyPreservingSimplifier.html sample Java implementation notes]), | |||
* {{code|VW_SIMPLIFIER}} (see [https://en.wikipedia.org/wiki/Visvalingam–Whyatt_algorithm Wikipedia]), or | |||
* {{code|NONE}}. | |||
'''Parameters''' | '''Parameters''' | ||
{{param| | {{param|vbl|A JSON object containing the VBL to be added to the token. Use {{func|getTokenVBL}}, {{func|getTokenHillVBL}}, or {{func|getTokenPitVBL}} to get VBL from another token.}} | ||
{{param|id|}} | {{param|id|OPTIONAL: The token {{code|id}} which becomes the container for the Hill VBL being set. Defaults to the [[Current Token]].}} | ||
|example= | |||
Transfer Hill VBL from one token to another: | |||
<syntaxhighlight lang="mtmacro"> | |||
[h: vbl = getTokenVBL("Door, Steel")] | |||
[h: setTokenHillVBL(vbl, "Door, Wood")] | |||
</syntaxhighlight><br /> | |||
Erase Hill VBL from a token: | |||
<syntaxhighlight lang="mtmacro"> | |||
[r: finalVblData = "{'shape':'none'}"] | |||
[r: setTokenHillVBL(finalVblData)] | |||
</syntaxhighlight><br /> | |||
Auto-generate Hill VBL for the [[Current Token]]: | |||
<syntaxhighlight lang="mtmacro"> | |||
[h: options = json.set("{}", "shape", "auto", "sensitivity", 10, "inverse", 0, "level", 2, "method", "DOUGLAS_PEUCKER_SIMPLIFIER", "r", 0, "g", 0, "b", 0, "a", 255)] | |||
[h: setTokenHillVBL(options)] | |||
</syntaxhighlight><br /> | |||
|also= | |||
[[Introduction to Vision Blocking]], {{func|getTokenVBL}}, {{func|drawVBL}}, {{func|eraseVBL}} | |||
}} | }} | ||
[[Category:Miscellaneous Function]] | |||
[[Category:VBL Function]] | [[Category:VBL Function]] |
Latest revision as of 23:59, 5 June 2023
This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.
setTokenHillVBL() Function
Note: This function can only be used in a Trusted Macro
Usage
setTokenHillVBL(jsonarray)
setTokenHillVBL(jsonarray, id)
This function is used to attach the Hill VBL passed in as a JSON object to a token. The JSON object may be be created by calling getTokenVBL() (or similar) on a different token, and may also be used with any of the drawVBL() or eraseVBL() functions.
Token VBL of any kind moves with the token, can be set under the VBL tab on the Token Editor Dialog and is colored YELLOW. Normal VBL is static, can be created with the VBL drawing tools or with the use of the VBL functions, and is colored BLUE.
The method
parameter in the JSON object must use one of the following (a link is provided for descriptions of each):
DOUGLAS_PEUCKER_SIMPLIFIER
(see Wikipedia),TOPOLOGY_PRESERVING_SIMPLIFIER
(see sample Java implementation notes),VW_SIMPLIFIER
(see Wikipedia), orNONE
.
Parameters
vbl
- A JSON object containing the VBL to be added to the token. Use getTokenVBL(), getTokenHillVBL(), or getTokenPitVBL() to get VBL from another token.id
- OPTIONAL: The tokenid
which becomes the container for the Hill VBL being set. Defaults to the Current Token.
Example
[h: vbl = getTokenVBL("Door, Steel")]
[h: setTokenHillVBL(vbl, "Door, Wood")]
Erase Hill VBL from a token:
[r: finalVblData = "{'shape':'none'}"]
[r: setTokenHillVBL(finalVblData)]
Auto-generate Hill VBL for the Current Token:
[h: options = json.set("{}", "shape", "auto", "sensitivity", 10, "inverse", 0, "level", 2, "method", "DOUGLAS_PEUCKER_SIMPLIFIER", "r", 0, "g", 0, "b", 0, "a", 255)]
[h: setTokenHillVBL(options)]