getLights: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
==Function getLights==
{{MacroFunction
|name=getLights
|description=Returns a string list containing the names of the [[Map:light source{{!}}light source]]s that are on for the [[Token:Current Token{{!}}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 [[Macros:json array{{!}}json array]] is returned.
* Otherwise a [[Macros:string list{{!}}string list]] is returned with the delimiter passed in.


Returns a string list containing the names of the [[Map:light source|light source]]s that are on for the [[Token:Current Token|Current Token]]. The type of the value returned depends on the delimiter parameter.
|usage=
* 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 [[Macros:json array|json array]] is returned. '''(as of MapTool 1.3b49)'''
* Otherwise a [[Macros:string list|string list]] is returned with the delimiter passed in.
 
===Usage===
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: lights = getLights()]
[h: lights = getLights()]
Line 14: Line 14:
</source>
</source>
Where  
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.
* 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 ","
* 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.
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.


===Examples===
|examples=
To get a [[Macros:string list|string list]] of all of the [LightSource:light source|]]s that the current [[Token:token|token]] has on.
To get a [[Macros:string list{{!}}string list]] of all of the [LightSource:light source]]s that the current [[Token:token{{!}}token]] has on.
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[getLights()]
[getLights()]
</source>
</source>


To get a [[Macros:string list|string list]] of the [LightSource:light source|]]s that the current [[Token:token|token]] has on with the [[LightSource:type| lighet source type|]] of "Generic".
To get a [[Macros:string list{{!}}string list]] of the [LightSource:light source]]s that the current [[Token:token{{!}}token]] has on with the [[LightSource:type{{!}} lighet source type]] of "Generic".
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[getLights("Generic")]
[getLights("Generic")]
</source>
</source>
|changes=
* '''1.3b49''' - Added ''"json"'' delimiter option.
}}
[[Category:Light Function]]
[[Category:Token Function]]

Revision as of 03:57, 7 March 2009

getLights() Function

Returns a string list containing the names of the light sources that are on for the Current Token. The type of the value returned depends on the delimiter parameter.
  • If the delimiter is not specified then a string list is returned with the default value of ',' is used.
  • If the delimiter "json" then a json array is returned.
  • Otherwise a string list is returned with the delimiter passed in.

Usage

[h: lights = getLights()]
[h: lights = getLights(type)]
[h: lights = getLights(type, delim)]
[h: lights = getLights("*", delim)]

Where

  • type is the type of light source (e.g. "Generic" or "D20"). If it is not specified then all light sources that are on for the token are returned.
  • delim is the delimiter used to separate values in the 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 light source types then you can use the special value "*" for type.

Examples

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

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

[getLights("Generic")]

Version Changes

  • 1.3b49 - Added "json" delimiter option.