You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/docs/about/faq.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,7 +89,7 @@ Roll buttons are HTML elements with specific attributes that execute designated
89
89
90
90
{{< details "Q: How are Custom Sheet attributes handled in Beacon?" >}}
91
91
92
-
Beacon gives you the ability to transition your Custom Sheet attributes to new attributes you create in Beacon. This means that when a user updates their sheet to the new Beacon sheet, their Custom Sheet attribute can be mapped to Beacon attributes using the `convertLegacyMacroAttributes` function. Sheet developers can define how to handle Custom Sheet attribute values to ensure compatibility with existing macros.
92
+
Beacon gives you the ability to transition your Custom Sheet attributes to new attributes you create in Beacon. This means that when a user updates their sheet to the new Beacon sheet, their Custom Sheet attribute can be mapped to Beacon attributes using the `handleFallbackAttributes` function. Sheet developers can define how to handle Custom Sheet attribute values to ensure compatibility with existing macros.
93
93
{{< /details >}}
94
94
95
95
@@ -105,9 +105,9 @@ Tokens represent characters or objects on Roll20 Tabletop (VTT). Functions like
105
105
{{< /details >}}
106
106
107
107
108
-
{{< details "Q: What is the role of the convertLegacyMacroAttributesArgs type?" >}}
108
+
{{< details "Q: What is the role of the handleFallbackAttributesArgs type?" >}}
109
109
110
-
The `convertLegacyMacroAttributesArgs` type defines the arguments used for handling Custom Sheet macro attributes. It includes the attribute name, character ID, and character data needed for mapping Custom Sheet attributes to the new sheet structure.
110
+
The `handleFallbackAttributesArgs` type defines the arguments used for handling not found/defined Custom Sheet macro attributes. It includes the attribute name, character ID, and character data needed for mapping Custom Sheet attributes to the new sheet structure.
Copy file name to clipboardExpand all lines: content/docs/components/InitRelay.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,9 +67,9 @@ These components are crucial for handling actions, computations, macros, and rol
67
67
target="_blank"
68
68
>}}
69
69
{{< link-card
70
-
title="Custom Sheet Macro Attributes"
71
-
description="Macro attributes handle the conversion of legacy macro attributes to the new format used in the Beacon SDK. This ensures compatibility with older character sheets and macros, allowing for a smooth transition to the new system."
description="Fallback methods to allow Sheet Developers to handle attributes, roll templates and actions not found/defined in the sheet. These methods can also help to ensure compatibility with older character sheets macros, roll templates and actions allowing for a smooth transition to the new system."
Copy file name to clipboardExpand all lines: content/docs/components/dispatch.md
+31-19Lines changed: 31 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Join to get access to the Beacon SDK, the community sheet repo for Beacon sheet,
24
24
25
25
The dispatch is returned by the `initRelay` and provides methods for sending commands from the character sheet back to the host. Except when specified every method below will return a promise.
26
26
27
-
####update
27
+
## update
28
28
```javascript
29
29
dispatch.update({
30
30
options: { overwrite?: boolean }
@@ -35,7 +35,7 @@ The `update` method sends character changes to the host (Roll20 Tabletop or Roll
35
35
36
36
The partial character passed in here must contain the character's id, and can contain any combination of the attributes, bio, and gmNotes properties. When updating a character’s attributes, only include those attributes that have changed.
37
37
38
-
####updateCharacter
38
+
## updateCharacter
39
39
```javascript
40
40
dispatch.updateCharacter({
41
41
character: Partial<Character>
@@ -45,7 +45,7 @@ Like the `update` method, `updateCharacter` sends character changes to the host
45
45
46
46
However, this method takes a full set of character attributes as the character argument, and automatically computes the diff with existing character attributes, so that only changed attributes are sent to the data store.
@@ -58,7 +58,7 @@ If messageId is omitted, the roll will be associated with a new chat message and
58
58
59
59
The method returns a promise that resolves with an object containing the messageId and the RollResult (see Types). The roll result is returned in the same format as in the non-beacon dice rolls computed roll system.
60
60
61
-
####post
61
+
## post
62
62
```javascript
63
63
dispatch.post({
64
64
characterId: string,
@@ -78,7 +78,7 @@ The secret option is ignored unless whisper is also set, toggling to true will c
78
78
79
79
Like roll, messageId can be provided to update an existing chat message, but if omitted the method will generate a new messageId and post a new chat message. The method returns the messageId.
80
80
81
-
####query
81
+
## query
82
82
```javascript
83
83
dispatch.query(options: Swal2Options): {
84
84
isConfirmed: boolean,
@@ -102,7 +102,7 @@ The `query` method takes an options object and uses them to display a [SweetAler
`perform` executes the specified action on behalf of the character (designated by the character id), passing in args to the action method. This method can perform actions on behalf of any character, even a character that the sheet does not have data for.
114
114
115
-
####getComputed
115
+
## getComputed
116
116
```javascript
117
117
dispatch.getComputed({
118
118
characterId: string,
@@ -132,7 +132,7 @@ dispatch.setComputed({
132
132
```
133
133
`getComputed` and `setComputed` are both nearly identical in how they are called, taking a character id and a property with the name of the computed property you wish to get or set, and an array of string args. Both methods return a promise that resolves with the computed value.
134
134
135
-
####compendiumRequest
135
+
## compendiumRequest
136
136
```javascript
137
137
dispatch.compendiumRequest({
138
138
query: string
@@ -144,7 +144,7 @@ dispatch.compendiumRequest({
144
144
```
145
145
`compendiumRequest` executes an AJAX request to the compendium service’s graphQL endpoint. It takes in a graphQL query string written according to the Compendium service’s schema. The query string does not need to include the ruleSystem shortName as this is set automatically according to the campaign override or sheet.json value in the Roll20 Tabletop.
Like `compendiumRequest`, except that calls to this method are automatically debounced (at 100ms) and grouped together into a single request to the compendium service. Note that this method will only return the requested data, it does not return errors or extensions.
156
156
157
-
####getTokens
157
+
## getTokens
158
158
```javascript
159
159
dispatch.getTokens({
160
160
characterId: string
@@ -168,7 +168,7 @@ dispatch.getTokens({
168
168
```
169
169
`getTokens` requires a character id string and returns information about tokens on the user’s current page. The return value contains two arrays of tokens. The tokens array contains all tokens on the current page that represent the character whose id was provided to the method. The selected array contains any tokens that are currently selected, regardless of which character they represent. The returned token objects contain all of the token attributes available to the API, you can find documentation here and here.
170
170
171
-
####addToTracker
171
+
## addToTracker
172
172
```javascript
173
173
dispatch.addToTracker({
174
174
tokenId?: string,
@@ -182,7 +182,7 @@ dispatch.addToTracker({
182
182
```
183
183
`addToTracker` adds or updates a single item in the turn tracker. Passing in a tokenId will add the specified token to the tracker, while passing in custom with a name and an optional image url (img) will add a custom item, not connected to any character or token. A round calculation string can be added via the optional formula parameter. value is the initiative number for the item.
184
184
185
-
####addMacrosToHost
185
+
## addMacrosToHost
186
186
```javascript
187
187
dispatch.addMacrosToHost({
188
188
macro: {
@@ -206,7 +206,7 @@ Passing in a `location` will add it either to the player's macroBar, the charact
206
206
207
207
[See Actions page for examples on the usuage of `addMacrosToHost`](/beacon-docs/docs/components/actions)
208
208
209
-
####getCharacterMacros
209
+
## getCharacterMacros
210
210
```javascript
211
211
dispatch.getCharacterMacros({
212
212
args: {
@@ -224,7 +224,7 @@ dispatch.getCharacterMacros({
224
224
```
225
225
`getCharacterMacros` gets a specific character’s macros. The `ids` returned from this list can be used in conjuction with `addMacrosToHost` update their locations. In jumpgate games, character macros can also be found in the `Advanced Tools -> Characters Macros` tab.
226
226
227
-
####setContainerSize
227
+
## setContainerSize
228
228
```javascript
229
229
dispatch.setContainerSize({
230
230
args: {
@@ -235,7 +235,7 @@ dispatch.setContainerSize({
235
235
```
236
236
`setContainerSize` updates the size of the container which holds the sheet shared settings. Returns a promise that can be awaited. This can be used in conjunction with something like the ResizeSensor event listener from npm: css-element-queries to automatically resize the container on the host.
`updateTokensByCharacter` updates a particular character’s default token as well as all existing tokens representing that character. Returns a promise that can be awaited.
248
248
249
-
####updateTokensByIds
249
+
## updateTokensByIds
250
250
```javascript
251
251
dispatch.updateTokensByIds({
252
252
args: {
@@ -257,7 +257,7 @@ dispatch.updateTokensByIds({
257
257
```
258
258
`updateTokensByIds` updates a single or several tokens. Returns a promise that can be awaited.
259
259
260
-
####autoLinkText
260
+
## autoLinkText
261
261
```javascript
262
262
dispatch.autoLinkText({
263
263
args: {
@@ -267,7 +267,7 @@ dispatch.autoLinkText({
267
267
```
268
268
`autoLinkText` goes through the text to find handout names between square brackets and converts them into links with the handoutID. For example in a game with a handout named `Dragon`, passing in the text string of `this is a [Dragon]` to autoLinkText returns something similar to this is a `<a href="https://journal.roll20.net/8je02j0kd02k">Dragon</a>`.
`openDialogFromLink` opens the supplied urlString through the Roll20 Tabletop.
279
279
- If the url is for a handout, it will open the corresponding handout in the campaign. This will also check if the user opening the link has access to the handout.
280
280
- If the url is for a compendium, it will open a pop up to the compendium page, it will also check to ensure the user has access to view the page.
281
-
- If the url is for an external page, a confirmation pop up will display to warn the user that the link is for an external site and open a new tab in their main window if confirmed.
281
+
- If the url is for an external page, a confirmation pop up will display to warn the user that the link is for an external site and open a new tab in their main window if confirmed.
282
+
283
+
## writeToClipboard
284
+
```javascript
285
+
dispatch.writeToClipboard(text)
286
+
```
287
+
`writeToClipboard` allows writing text such as macro commands or roll templates from the sheet to the player's OS clipboard.
288
+
289
+
This command will trigger a dialog model to pop up in the host, the dialog will include a warning urging the player to fully understand what their copying to their clipboard; The dialog will also include a preview of the text.
290
+
291
+
Clicking `allow` will copy the text to the player's clipboard, while clicking `deny` will prevent it and log `"user refused copy action"`
{{< 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
+
When utilizing Macros, Roll Templates, or Actions within the Roll20 Tabletop or Roll20 Characters (both refered to as host throughout this page), there are instances where a older Custom Sheet macros might need to be employed for a Beacon sheet.
26
+
27
+
This scenario commonly arises when transitioning from an existing older Custom Sheet to a Beacon sheet. During such transitions, it's possible that the attributes called from the older Custom Sheet macros, roll templates or actions may not align with the structure of attributes in the Beacon Sheet.
In older Beacon SDK versions, this function was previously named `convertLegacyMacroAttributes`.
33
+
{{< /callout >}}
34
+
35
+
The `handleFallbackAttributes` method allows us to determine the mapping strategy for older Custom Sheet attributes to the new Beacon Sheet.
36
+
37
+
```typescript
38
+
initRelay({
39
+
handleFallbackAttributes: (messages: {
40
+
attribute:string,
41
+
characterId:string,
42
+
character:Character
43
+
}) => {}: string|number|null,
44
+
}): Promise<Dispatch>
45
+
```
46
+
47
+
48
+
This method is defined during the initial SDK initialization process and is invoked by the host when it attempts to parse a macro and encounters a failure in locating an attribute's value during an macro's execution.
49
+
50
+
Beacon Sheet actions will typically search through the defined computed properties before resorting to the `handleFallbackAttributes` method.
51
+
52
+
Returning a `null` value from this method will display the following error message to the user: `Unable to find attribute with the name ${attribute}`
53
+
54
+
The method's purpose is to return a value that will be substituted in the macro. However, it grants us the autonomy to devise the preferred approach for handling older Custom Sheet attribute values.
In older Beacon SDK versions, this function was previously named `handleLegacyRollTemplates`.
60
+
{{< /callout >}}
61
+
62
+
Since Beacon sheets no longer require or use roll templates as previously defined in older custom sheets, there will be times where an older Custom Sheet roll template might need to be handled by a Beacon Sheet.
63
+
64
+
This scenario commonly arises when transitioning from an existing older Custom Sheet to a Beacon sheet. During such transitions, it's possible that an older Custom Sheet roll template might need to be called or handled.
65
+
66
+
We can use the `handleFallbackRollTemplates` to determine how to handle these cases.
67
+
68
+
```typescript
69
+
initRelay({
70
+
handleFallbackRollTemplates: (message: {
71
+
templateName:string, // name of the template that triggered this method
72
+
properties:Record<string, any>, // a list of the values and formulas for rolls and macro in the template
73
+
// along with values for other properties in the template
74
+
dispatch:Dispatch,
75
+
playerid:string ,
76
+
originalInput:string// the original text input for the entire roll template string
77
+
}) => {}: any,
78
+
}): Promise<Dispatch>
79
+
```
80
+
81
+
The properites object will also include a plainText key for roll template arguments not inside the curly brace syntax.
82
+
83
+
```typescript
84
+
{
85
+
//... other arguments
86
+
properties: {
87
+
attack: { value: 12, formula: '1d20' },
88
+
damage: { value: 5, formula: '2d6' },
89
+
foo: { value: 'bar' },
90
+
name: {
91
+
formula: "@{Helga|name}"
92
+
value: "Helga"
93
+
},
94
+
plainText: ['apicallback', 'apple=red'],
95
+
something: {
96
+
value: "I went to get tacos"
97
+
},
98
+
............
99
+
}
100
+
}
101
+
```
102
+
103
+
## handleFallbackActions
104
+
105
+
There might be times when an action isn't found in the Beacon Sheet's action list.
106
+
107
+
This scenario commonly arises when transitioning from an existing older Custom Sheet to a Beacon sheet. During such transitions, it's possible that an older action name might need to be handled in the Beacon Sheet.
108
+
109
+
`handleFallbackActions` can be used to handle these scenarios or as a general fallback for actions.
110
+
111
+
```typescript
112
+
initRelay({
113
+
handleFallbackActions: (message: {
114
+
command:string, // The action command/name
115
+
characterId:string,
116
+
args:Record<string, any>, // Arguments passed into action
0 commit comments