setLayer: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function setLayer== {{TrustedOnlyFunction}} Sets the map layer that the Token:Current Token is on. The map layer is one of: * TOKEN * BACKGROUND...)
 
No edit summary
 
(12 intermediate revisions by 6 users not shown)
Line 1: Line 1:
==Function setLayer==
{{MacroFunction
{{TrustedOnlyFunction}}
|name=setLayer
|trusted=true
|version=1.3b48
|description=
Sets the [[Introduction to Mapping#introduction to Mapping|Map Layer]] that a [[Token]] is on.


Sets the [[Map:map layer|map layer]] that the [[Token:Current Token|Current Token]] is on.
The [[Introduction to Mapping#introduction to Mapping|Map Layer]] is one of:
The [[Map:map layer|map layer]] is one of:
* {{code|TOKEN}}
* TOKEN
* {{code|GM}} also known as Hidden
* BACKGROUND
* {{code|OBJECT}}
* GM
* {{code|BACKGROUND}}
* OBJECT
 


===Usage===
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
setLayer(layer)
setLayer(layer, id)
setLayer(layer, id, forceshape)
setLayer(layer, id, forceshape, mapname)
</syntaxhighlight>
'''Parameters'''
{{param|layer|The layer to move the [[Token]] to.}}
{{param|id|The token {{code|id}} of the token which has its layer set, defaults to the [[Current 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|mapname|The name of the map to find the token.  Defaults to the current map.}}
 
|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)]
[h: setLayer(layerName)]
</source>
</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)]
</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]]

Latest revision as of 20:56, 14 March 2023

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 Hidden
  • OBJECT
  • BACKGROUND
 

Usage

setLayer(layer)
setLayer(layer, id)
setLayer(layer, id, forceshape)
setLayer(layer, id, forceshape, mapname)

Parameters

  • layer - The layer to move the Token to.
  • id - The token id of the token which has its layer set, defaults to the Current Token.
  • forceshape - If true(1), change the token shape type to TOP_DOWN if the layer is OBJECT, and to a shape reflecting its image if the layer is TOKEN. Defaults to true(1).
  • mapname - The name of the map to find the token. Defaults to the current map.

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.