Skip to content

Commit 3d7b2ce

Browse files
authored
Merge pull request #53 from Roll20/feature/CSC-2158
CSC-2158 add documentation for beacon sheets
2 parents 7cf5e91 + 53e381a commit 3d7b2ce

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

content/docs/components/modApi.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: "Mod API Integration"
3+
description: ""
4+
summary: ""
5+
date: 2024-09-16T16:12:37+02:00
6+
lastmod: 2024-09-16T16:12:37+02:00
7+
draft: false
8+
weight: 100
9+
toc: true
10+
sidebar:
11+
collapsed: true
12+
seo:
13+
title: "" # custom title (optional)
14+
description: "" # custom description (recommended)
15+
canonical: "" # custom canonical URL (optional)
16+
noindex: false # false (default) or true
17+
---
18+
19+
{{< callout context="tip" title="Join the Closed Beta" icon="outline/rocket" >}}
20+
The Beacon SDK is currently in closed Beta. Please complete the [form](https://forms.gle/XXnj1SbfmYnUq8Hu9) to sign up for the closed beta.
21+
22+
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.
23+
{{< /callout >}}
24+
25+
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`.
26+
27+
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.
28+
29+
Because this script will be running on a virtual machine rather than your browser, it has a few requirements:
30+
- 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 both `sheet.js` and `worker.js` can use. Read more about initializing the relay [here](/docs/components/InitRelay)
31+
- Dom elements like `document` and `window` do not exist on the virtual machine, so trying to access properties of these objects (as in `window.location` or `window.addEventListener()`) will crash the script. Note that some NPM packages, such as `vue-router`, try to access the on initialization, so just including them may cause an error. If you want to save and access variables from `window`, consider instead saving them as properties on `globalThis`, which is available in both browser and virtual machine.
32+
- The compiled .js file should not use `import` (including `import.meta`, etc.) or `export`.

content/docs/gettingstarted/releasingasheet.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ You must have a build command that will produce the minified production-ready co
4646
- `sheet.js`
4747
- `sheet.css`
4848
- `host.css` (optional) - _Used for sheet rolls made to chat (roll templates)._
49+
- `worker.js` (optional) - _Enables Mod (API) Script integration. Read more [here](/docs/components/modApi)_
4950
- an Image Folder (optional) - _Used to contain fonts and images used in the sheet._
5051

5152
We will use this build command to get these sheet files to use for your sheet. Make sure to test these files locally first before moving to Step 3.

0 commit comments

Comments
 (0)