setTokenPitVBL: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(Created stub for setTokenPitVBL 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=setTokenPitVBL
|name=setTokenPitVBL
|proposed=false
|trusted=true
|version=1.12
|version=1.12
|description=
|description=Sets the Pitl VBL of a token to that given in the JSON object parameter.


|usage=
|usage=
<syntaxhighlight lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
setTokenPitVBL(jsonarray)
setTokenPitVBL(jsonarray, id)
setTokenPitVBL(jsonarray, id)
</syntaxhighlight>
</syntaxhighlight>
This function is used to attach the Pit 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|jsonarray|}}
{{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 Pit 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: setTokenPitVBL(vbl, "Door, Wood")]
</syntaxhighlight><br />
 
Erase Hill VBL from a token:
<syntaxhighlight lang="mtmacro">
[r: finalVblData = "{'shape':'none'}"]
[r: setTokenPitVBL(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: setTokenPitVBL(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.

setTokenPitVBL() Function

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

Introduced in version 1.12
Sets the Pitl VBL of a token to that given in the JSON object parameter.

Usage

setTokenPitVBL(jsonarray)
setTokenPitVBL(jsonarray, id)

This function is used to attach the Pit 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):

Parameters

Example

Transfer Hill VBL from one token to another:
[h: vbl = getTokenVBL("Door, Steel")]
[h: setTokenPitVBL(vbl, "Door, Wood")]

Erase Hill VBL from a token:

[r: finalVblData = "{'shape':'none'}"]
[r: setTokenPitVBL(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: setTokenPitVBL(options)]

See Also