
My first API script(!), inspired by a "Stupid Trick" proposed by Avi:
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. Using Token-mod to then move 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!
EDIT 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.
Code moved to github here:
https://github.com/djmoorehead/roll20-api-scripts/tree/master/DL%20Darkness
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
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 !dldark 15 true !dldark ?{buffer radius?|15} true false
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.