getLights: Difference between revisions
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
Line 5: | Line 5: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
getLights() | getLights() | ||
getLights(type) | getLights(type) | ||
Line 21: | Line 21: | ||
|examples= | |examples= | ||
To get a [[Macros:string list{{!}}string list]] of all of the [[Introduction to Lights and Sights|light source]]s that the current [[Token:token{{!}}token]] has on. | To get a [[Macros:string list{{!}}string list]] of all of the [[Introduction to Lights and Sights|light source]]s that the current [[Token:token{{!}}token]] has on. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[getLights()] | [getLights()] | ||
</source> | </source> | ||
To get a [[Macros:string list{{!}}string list]] of the [[Introduction to Lights and Sights|light source]]s that the current [[Token:token{{!}}token]] has on with the light source type of "Generic". | To get a [[Macros:string list{{!}}string list]] of the [[Introduction to Lights and Sights|light source]]s that the current [[Token:token{{!}}token]] has on with the light source type of "Generic". | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[getLights("Generic")] | [getLights("Generic")] | ||
</source> | </source> | ||
Line 32: | Line 32: | ||
'''Getting all lights from campaign properties'''<br> | '''Getting all lights from campaign properties'''<br> | ||
The information provided by [[getInfo]] can be used to extract all light source names defined in the campaign properties. The following provides all names in a [[JSON Array]]: | The information provided by [[getInfo]] can be used to extract all light source names defined in the campaign properties. The following provides all names in a [[JSON Array]]: | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: json.path.read(json.get(getInfo("campaign"), "light sources"), ".[*][*]['name']")] | [r: json.path.read(json.get(getInfo("campaign"), "light sources"), ".[*][*]['name']")] | ||
</source> | </source> | ||
To restrict the query to only one specific type of light sources, you can use the following and replace {{code|'TYPE'}} with the desired type (note that single quotes are needed for this string, because double quotes are already in use): | To restrict the query to only one specific type of light sources, you can use the following and replace {{code|'TYPE'}} with the desired type (note that single quotes are needed for this string, because double quotes are already in use): | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: json.path.read(json.get(getInfo("campaign"), "light sources"), ".['TYPE'][*]['name']")] | [r: json.path.read(json.get(getInfo("campaign"), "light sources"), ".['TYPE'][*]['name']")] | ||
</source> | </source> |
Revision as of 18:13, 14 March 2023
getLights() Function
Usage
<syntaxhighlight lang="mtmacro" line> getLights() getLights(type) getLights(type, delim) getLights(type, delim, id) getLights(type, delim, id, mapname) </source>
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 tokenid
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
<syntaxhighlight lang="mtmacro" line> [getLights()] </source>
To get a string list of the light sources that the current token has on with the light source type of "Generic". <syntaxhighlight lang="mtmacro" line> [getLights("Generic")] </source>
Getting all lights from campaign properties
The information provided by getInfo can be used to extract all light source names defined in the campaign properties. The following provides all names in a JSON Array:
<syntaxhighlight lang="mtmacro" line>
[r: json.path.read(json.get(getInfo("campaign"), "light sources"), ".[*][*]['name']")]
</source>
To restrict the query to only one specific type of light sources, you can use the following and replace 'TYPE'
with the desired type (note that single quotes are needed for this string, because double quotes are already in use):
<syntaxhighlight lang="mtmacro" line>
[r: json.path.read(json.get(getInfo("campaign"), "light sources"), ".['TYPE'][*]['name']")]
Version Changes
- 1.3b49 - Added "json" delimiter option.
- 1.5.4 - Added
id
andmapname
parameter options.