A Roll20 Mod (API) script that estimates how much light is falling on a token, as a percentage. Useful for abilities that depend on lighting, such as "can turn invisible in dim light or darkness".
Path Math v1.7 or later. One-click installs pull it in automatically.
Works on both the classic tabletop (path walls) and Jumpgate (pathv2 walls).
| Command | Who | What it does |
|---|---|---|
!checklight |
GM (players too, if allowed) | Reports the light level of every selected token. |
!checklight --dmOnly |
GM | Toggles whether players may use !checklight. |
Commands are not case sensitive.
Select one or more tokens and type !checklight. Each token gets its own report. Anything else in the selection (walls, drawings, text) is ignored. With no token selected, you are whispered a reminder.
- Global light: the page's daylight mode level, if it is switched on.
- Direct bright light: the token is inside the bright radius of a light it has line of sight to. This counts as 100%.
- Sources of dim light: how many dim lights reach the token, and the total light level they add up to.
- Darkness: no light reaches the token.
- "Partially": the centre of the token is just outside a light's radius, but part of the token is inside it.
GM only by default. !checklight --dmOnly switches player access on or off. Only a GM can change the setting, and it is remembered between sessions.
- A GM's reports are whispered to the GM.
- A player's reports are whispered to that player, and only for tokens they can select.
- Every token on the page that emits bright or dim light is a light source, apart from those on the GM layer. A token carrying its own light is lit by it.
- A light is blocked if a wall on the dynamic lighting layer crosses the straight line between the centre of the light and the centre of the token.
- Transparent barriers never block light. One-way walls block it from one side only.
- Bright light counts as 100%. Dim light is 50% at the edge of the bright radius and fades with distance. Several dim lights add together, up to a maximum of 100%.
- Light ranges use the page's grid size and scale settings.
- Line of sight is centre to centre. A large token can be partly lit while its centre is in shadow, and the reverse. Light sources work best at one grid square in size.
- Doors and windows are not considered. A closed door does not block light.
- Directional lights are treated as full circles.
- The script measures light on the token, not what the token can see. Night vision is not considered.
With the Meta Toolbox (Plugger) installed, the script registers a checklight() plugin:
{& eval}checklight(){& /eval}
It returns the total light level of the first selected token as a number from 0 to 1. This plugin is not affected by the --dmOnly setting.
checkLightLevel.isLitBy(tokenOrTokenId) returns a LitBy object:
/**
* @typedef {object} LitBy
* @property {?boolean} bright - token is lit by bright light, null on error
* @property {?array} dim - dim light emitters found to be illuminating the token, null on error
* @property {?float} daylight - token is in <float between 0 and 1> daylight, false on no daylight, null on error
* @property {?float} total - total light multiplier from adding all sources, max 1, null on error
* @property {boolean} partial - if true, no light source completely covers the token. Not set on error
* @property {?string} err - error message, only on error
*
* @param {string | object} tokenOrTokenId - Roll20 Token object, or token ID string
* @returns {LitBy}
*/
- Walls on Jumpgate (
pathv2objects) now block light. Requires Path Math 1.7 or later. - Rotated, scaled and curved walls on the classic tabletop are now handled.
- Fixed one-way walls blocking light from both sides for some drawing directions.
- Fixed a crash when something other than a token was selected.
- Added the
--dmOnlysetting, so a GM can let players use the command. isLitBy()now returns its error message inerr.