Starting a new thread as the previous one was closed due to inactivity. (Initial post copied here for reference) This script was inspired by a "Stupid Trick" proposed by Avi: <a href="https://app.roll20.net/forum/post/5899495/stupid-roll20-tricks-and-some-clever-ones/?pageforid=8900893#post-8900893" rel="nofollow">https://app.roll20.net/forum/post/5899495/stupid-roll20-tricks-and-some-clever-ones/?pageforid=8900893#post-8900893</a> Avi represents magical darkness by drawing a grid within a circle on the DL layer. It blocks line of sight from both the exterior and the interior, without covering tokens on the object layer like a big black circle token does. Players controlling characters within the darkness will see only their token. Cool idea, Avi! Rather than drawing this manually every time, I thought this would be a good use of API scripting to automate. Also, it sounded like a fun first javascript project ever for me :) To use: Create a dummy character whose token has the desired size and image of the darkness generated (e.g. 20ft radius black circle) Add an Ability macro to call the new !dldark script and set as a token action Ideally used in conjunction with Token-mod to send the darkness token to the map layer (e.g. !token-mod --set layer|map) Added this functionality directly to !dldark So, drag it out and click a token action to summon your darkness. The script draws an approximated circle (stole a portion from TheAaron's !dlcircle script) on the DL layer of the same diameter as the token's width, and using the token's position. Additionally, interior gridlines are drawn within the circle to block LoS for those within the darkness. The entire drawing can be moved easily as one object by the GM if there is a need. Moving the darkness token to the map layer allows character tokens within the darkness to be seen clearly by the DM, while the player will only see his/her token. Note that if Restrict Movement is ON, then the GM will have to move character tokens in/out/within the darkness, but them's the breaks! Support my work on Patreon I've been asked by a few folks if they can provide support in appreciation for a script or other help. If you find yourself falling into that group, too, then thank you! If not, no worries - it's not why I do this. I just want everyone to have as much fun as possible playing the games that they love! Disclaimer: Patreon campaigns are not affiliated with Roll20. Contributions are entirely voluntary and Roll20 cannot provide support or refunds for contributions. Syntax: !dldark < buffer > < makeGrid > < sendToMapLayer >
" buffer " < # > Optional. Default = 0
reduce the radius of the darkness by this many pixels.
allows the source of the darkness to be seen at the outer border of the darkness.
" makeGrid " < true / false > Optional. Default = true
draw a grid inside of the darkness circle.
the grid will be aligned with the map grid based on page settings
" SendToMapLayer " < true / false > Optional. Default = true
send the source token to the map layer after creating the DL path?
if true, will send to map layer and perform a z-order "ToFront"
if false, will keep on token layer and perform a z-order "ToBack" Example syntax: !dldark makes darkness circle all the way to the token perimeter, sends source token to map layer
!dldark 15 true leaves a 15 pixel buffer before darkness starts, draws grid inside circle, sends source token to map layer
!dldark ?{buffer radius?|15} true false queries for darkness buffer, draws grid, source token remains on object layer De-linking syntax (v0.3 and later): !dldarkclear token unlinks selected token and corresponding dynamic lighting path (requires token selection) !dldarkclear tok (Alias) unlinks selected token and corresponding dynamic lighting path (requires token selection) !dldarkclear page unlinks all tokens and corresponding dynamic lighting paths from the current page (requires token selection) !dldarkclear campaign unlinks all tokens and corresponding dynamic lighting paths from the ENTIRE CAMPAIGN (Use caution!) Versions v0.2 -- updates include (1) optional "buffer" that brings the radius of the darkness in a bit so players can see the edge of the effect causing the darkness, (2) interior grid optional , (3) automatically aligns the DL grid with the actual map grid (based on page settings), (4) supports gridless maps , and (5) gives the option whether or not to move the source token to the map layer . v0.3 -- Darkness paths are now linked to the source token . When the token is moved, the darkness will follow automatically. If the token is deleted, the darkness path is automatically deleted as well. Added the optional !dldarkclear command, which will de-link the source token and darkness path for a selected token, entire page, or the entire campaign, depending on arguments passed to the command (see example syntax above). Full code can be found here: <a href="https://github.com/djmoorehead/roll20-api-scripts/tree/master/DL%20Darkness" rel="nofollow">https://github.com/djmoorehead/roll20-api-scripts/tree/master/DL%20Darkness</a> Some screenshots. First, the darkness token is dragged to the map (20ft radius, in this case) After the !dldark script is run, in both GM and player view modes. (Note, token-mod was used in the screenshots, too, so the darkness token is now on the map layer): Edited: token is now moved to map layer as part of !dldark script (optional). Here is the player view when inside of the darkness Animated gif (click to play). Cloudkill in a tavern. What could go wrong? This example also uses my Spawn script to create the source token prior to creating the darkness effect.