setLayer: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) m (Applied Template:MacroFunction) |
No edit summary |
||
(16 intermediate revisions by 6 users not shown) | |||
Line 2: | Line 2: | ||
|name=setLayer | |name=setLayer | ||
|trusted=true | |trusted=true | ||
|description | |version=1.3b48 | ||
Sets the [[Map | |description= | ||
The [[Map | Sets the [[Introduction to Mapping#introduction to Mapping|Map Layer]] that a [[Token]] is on. | ||
* TOKEN | |||
* | The [[Introduction to Mapping#introduction to Mapping|Map Layer]] is one of: | ||
* | * {{code|TOKEN}} | ||
* | * {{code|GM}} also known as Hidden | ||
* {{code|OBJECT}} | |||
* {{code|BACKGROUND}} | |||
| |||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
setLayer(layer) | |||
setLayer(layer, tokenRef) | |||
setLayer(layer, tokenRef, forceshape) | |||
setLayer(layer, tokenRef, forceshape, mapRef) | |||
</syntaxhighlight> | |||
'''Parameters''' | |||
{{param|layer|The layer to move the [[Token]] to.}} | |||
{{param|tokenRef|Either the token [[getSelected|{{code|id}}]] or [[getTokenName|Token Name]] of the token. | |||
}} | |||
{{param|forceshape|}}If {{true}}, change the token shape type to TOP_DOWN if the layer is {{code|OBJECT}}, and to a shape reflecting its image if the layer is {{code|TOKEN}}. Defaults to {{true}}. | |||
{{param|mapRef|The Name or ID of the map to find the token. Defaults to the current map.}} | |||
{{Note|Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.}} | |||
|examples= | |||
When an NPC token is dead, send it to the Object layer, otherwise leave it where it is. | |||
<syntaxhighlight lang="mtmacro" line> | |||
[h: layerName = getLayer()] | |||
[h: layerName = if(state.Dead&&isNPC(), "OBJECT", layerName)] | |||
[h: setLayer(layerName)] | |||
</syntaxhighlight> | |||
Toggle a token between the Hidden and Token layers. | |||
<syntaxhighlight lang="mtmacro" line> | |||
[h: layerName = getLayer()] | |||
[h: layerName = if(layerName=="GM", "TOKEN", "GM")] | |||
[h: setLayer(layerName)] | [h: setLayer(layerName)] | ||
</ | </syntaxhighlight> | ||
|also= | |||
[[getLayer|getLayer()]] | |||
|changes= | |||
{{change|1.3b51|Added {{code|id}} parameter option.}} | |||
{{change|1.5.4|Added {{code|mapname}} parameter option.}} | |||
}} | }} | ||
[[Category:Token Function]] | [[Category:Token Function]] |
Latest revision as of 23:59, 10 May 2024
setLayer() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.3b48
Sets the Map Layer that a Token is on.
The Map Layer is one of:
TOKEN
GM
also known as HiddenOBJECT
BACKGROUND
Usage
setLayer(layer)
setLayer(layer, tokenRef)
setLayer(layer, tokenRef, forceshape)
setLayer(layer, tokenRef, forceshape, mapRef)
Parameters
layer
- The layer to move the Token to.tokenRef
- Either the tokenid
or Token Name of the token.
forceshape
- Iftrue
(1
), change the token shape type to TOP_DOWN if the layer isOBJECT
, and to a shape reflecting its image if the layer isTOKEN
. Defaults totrue
(1
).mapRef
- The Name or ID of the map to find the token. Defaults to the current map.
Token IDs are unique, but Token Names can be duplicated. Using Token Name when more than one token has the same name can produce unexpected results.
Examples
When an NPC token is dead, send it to the Object layer, otherwise leave it where it is.
[h: layerName = getLayer()]
[h: layerName = if(state.Dead&&isNPC(), "OBJECT", layerName)]
[h: setLayer(layerName)]
Toggle a token between the Hidden and Token layers.
[h: layerName = getLayer()]
[h: layerName = if(layerName=="GM", "TOKEN", "GM")]
[h: setLayer(layerName)]
See Also
Version Changes
- 1.3b51 - Added
id
parameter option. - 1.5.4 - Added
mapname
parameter option.