Mod API Integration
Join the Closed Beta
The Beacon SDK is currently in closed Beta. Please complete the form to sign up for the closed beta.
Join to get access to the Beacon SDK, the community sheet repo for Beacon sheet, the community sheet developers in discord, and the new sheet developer Roll20 permissions.
Character sheets created in Beacon are able to expose actions and computed values to Mod (API) Scripts. To do so, you must submit an additional Javascript file, worker.js
.
Mod (API) Scripts are a powerful tool that can potentially allow any player in a game to interact directly with game data. For security reasons, these scripts run on cloud-based virtual machines. In order to allow scripts to interact with a character sheet, a version of that sheet’s code needs to also be running on the same virtual machine. This is where worker.js
comes in.
Because this script will be running on a virtual machine rather than your browser, it has a few requirements:
- It should only include the call to
initRelay
, and the code for actions, computed values, and handler methods. It is recommended that the code for initializing the relay be exported from a separate file that bothsheet.js
andworker.js
can use. Read more about initializing the relay here - Dom elements like
document
andwindow
do not exist on the virtual machine, so trying to access properties of these objects (as inwindow.location
orwindow.addEventListener()
) will crash the script. Note that some NPM packages, such asvue-router
, try to access the on initialization, so just including them may cause an error. If you want to save and access variables fromwindow
, consider instead saving them as properties onglobalThis
, which is available in both browser and virtual machine. - The compiled .js file should not use
import
(includingimport.meta
, etc.) orexport
.