getLights: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 3: Line 3:
|version=1.3b48
|version=1.3b48
|description=Returns a string list containing the names of the [[Map:light source{{!}}light source]]s that are turned on for the [[Current Token]]. The type of the value returned depends on the delimiter parameter.  
|description=Returns a string list containing the names of the [[Map:light source{{!}}light source]]s that are turned on for the [[Current Token]]. The type of the value returned depends on the delimiter parameter.  
* If the delimiter is not specified then a [[Macros:string list{{!}}string list]] is returned with the default value of ',' is used.
* If the delimiter ''"json"'' then a [[JSON Array]] is returned.
* Otherwise a [[Macros:string list{{!}}string list]] is returned with the delimiter passed in.
 


|usage=
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
getLights()
getLights()
</source>
<source lang="mtmacro" line>
getLights(type)
getLights(type)
</source>
<source lang="mtmacro" line>
getLights(type, delim)
getLights(type, delim)
getLights(type, delim, id)
getLights(type, delim, id, mapname)
</source>
</source>
Where
* type is the [[LightSource:type {{!}}type of light source]] (e.g. "Generic" or "D20"). If it is not specified then all [[LightSource:light source{{!}}light source]]s that are on for the [[Token:token{{!}}token]] are returned.
* delim is the delimiter used to separate values in the [[Macros:string list{{!}}string list]]. If it is not specified then it defaults to ","


If you want to specify the delimiter but still want to fetch all of the [[LightSource:type {{!}} light source type]]s then you can use the special value "*" for type.
'''Parameters'''
{{param|type|The [[LightSource:light source type|light source type]], (e.g. "Generic", "D20"). If set to "*", all light sources are returned. Defaults to "*".}}
{{param|delim|The delimiter used to separate values in the [[Macros:string list{{!}}string list]]. If set to "json", a [[JSON Array]] is returned. Defaults to ",".}}
{{param|id|The token {{code|id}} of the token to change the light sources, defaults to the [[Current Token]]. {{TrustedParameter}} }}
{{param|mapname|The name of the map to find the token.  Defaults to the current map.}}


|examples=
|examples=
Line 36: Line 31:


|changes=
|changes=
* '''1.3b49''' - Added ''"json"'' delimiter option.
{{change|1.3b49|Added ''"json"'' delimiter option.}}
{{change|1.5.4|Added {{code|id}} and {{code|mapname}} parameter options.}}
 
}}
}}
[[Category:Light Function]]
[[Category:Light Function]]
[[Category:Token Function]]
[[Category:Token Function]]

Revision as of 20:06, 16 August 2019

getLights() Function

Introduced in version 1.3b48
Returns a string list containing the names of the light sources that are turned on for the Current Token. The type of the value returned depends on the delimiter parameter.

Usage

getLights()
getLights(type)
getLights(type, delim)
getLights(type, delim, id)
getLights(type, delim, id, mapname)

Parameters

  • type - The light source type, (e.g. "Generic", "D20"). If set to "*", all light sources are returned. Defaults to "*".
  • delim - The delimiter used to separate values in the string list. If set to "json", a JSON Array is returned. Defaults to ",".
  • id - The token id of the token to change the light sources, defaults to the Current Token.

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

  • mapname - The name of the map to find the token. Defaults to the current map.

Examples

To get a string list of all of the LightSource:light sources that the current token has on.
[getLights()]

To get a string list of the LightSource:light sources that the current token has on with the lighet source type of "Generic".

[getLights("Generic")]

Version Changes

  • 1.3b49 - Added "json" delimiter option.
  • 1.5.4 - Added id and mapname parameter options.