From RPTools Wiki
Jump to navigationJump to search

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.


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


  • 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.


To get a string list of all of the light sources that the current token has on.

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


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:

[r:"campaign"), "light sources"), ".[*][*]['name']")]

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):

[r:"campaign"), "light sources"), ".['TYPE'][*]['name']")]

Version Changes

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