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/actions.md
+34-1Lines changed: 34 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,4 +53,37 @@ The action's `method` receives a `props` object from the host containing the fol
53
53
- `messageId` (optional): A unique ID for an existing chat message. It's included in actions triggered from chat buttons to provide context for the original roll.
54
54
- `rolls` (optional): Included when action is triggered from a chat button. Contains the roll results of the original roll.
55
55
56
-
These methods can also receive an unlimited number of additional arguments. This is because these actions can be triggered by plain text via a macro. However, all additional arguments must be strings. Additionally, these methods can be synchronous or asynchronous and do not return a value.
56
+
These methods can also receive an unlimited number of additional arguments. This is because these actions can be triggered by plain text via a macro. However, all additional arguments must be strings. Additionally, these methods can be synchronous or asynchronous and do not return a value.
57
+
58
+
### addMacrosToHost
59
+
`addMacrosToHost` can be used to add the actions defined in initRelay above to either the macro bar or the token action bar. An example of this would be adding pre-defined actions to the token action bar for NPC characters or removing macros when types of
60
+
61
+
###### Example:
62
+
Assuming we have an action called "targeted_strength_check" that compares the npc character's strength vs a targeted token. We can add it to the token's action bar as well as the Character Macros tab with the following:
In a similar way we can remove it from the token action bar using `addMacrosToHost`, if for example our NPC changes and we want to reflect that in it's token actions by running the following:
79
+
80
+
```javascript
81
+
dispatch.addMacrosToHost({
82
+
macro: {
83
+
id:'npc_strength_check1',
84
+
}
85
+
})
86
+
```
87
+
88
+
The above will remove the `npc_strength_check1` action from the token bar but will still leave it in the Character Macros page:
Copy file name to clipboardExpand all lines: content/docs/components/dispatch.md
+57-32Lines changed: 57 additions & 32 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,36 +182,49 @@ 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.
`addActionsToHost` adds a specific action(macro) to an area of the Roll20 Tabletop UI; either the macrobar or the token action bar. Either sheetAction or action can be passed in but not both at the same time. The sheetAction arg should be passed in when an the action is to designated to a character. While the action arg should be passed in when the action is more generic.
199
+
`addMacrosToHost` previously `addActionsToHost`, adds a specific macro command to an area of the Roll20 Tabletop UI; either the macrobar or the token action bar.
200
+
201
+
Most things can be omitted like the `id` however atleast a `name` and `commmandString` are required when registering a new macro command, while it won't appear in the macroBar or tokenActionBar unless a location is pased in, it will appear in the Collections panel in the VTT.
202
+
203
+
Passing in a `characterId` will assign the macro as a character macro, displaying it in the `Advanced Tools -> Characters Macros` tab for a character sheet. Note: The Characters Macros tab is only available in Jumpgate games.
201
204
202
-
#### getActions
205
+
Passing in a `location` will add it either to the player's macroBar, the character's tokenActionBar or both. Omitting a location will remove it from the respective location or all locations. To update the location in this way, just the `id` of the macro is required to be passed in, note that removing a location or all locations will not delete the Macro and it will still be found in either the Collections panel or the Characters Macro tab.
206
+
207
+
[See Actions page for examples on the usuage of `addMacrosToHost`](/beacon-docs/docs/components/actions)
208
+
209
+
## getCharacterMacros
203
210
```javascript
204
-
dispatch.getActions({
211
+
dispatch.getCharacterMacros({
205
212
args: {
206
-
characterId?: string
213
+
characterId: string
207
214
}
208
215
}):Promise<{
209
-
actions?: {} | { [id: string]: ActionFromHost }
216
+
macros?: {} | { [id: string]: {
217
+
characterId: string,
218
+
name: string,
219
+
commandString: string,
220
+
onTokenBar: boolean,
221
+
onMacroBar: boolean
222
+
} }
210
223
}>
211
224
```
212
-
`getActions` gets a specific character’s actions(macro).
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.
213
226
214
-
####setContainerSize
227
+
## setContainerSize
215
228
```javascript
216
229
dispatch.setContainerSize({
217
230
args: {
@@ -222,7 +235,7 @@ dispatch.setContainerSize({
222
235
```
223
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.
235
248
236
-
####updateTokensByIds
249
+
## updateTokensByIds
237
250
```javascript
238
251
dispatch.updateTokensByIds({
239
252
args: {
@@ -244,7 +257,7 @@ dispatch.updateTokensByIds({
244
257
```
245
258
`updateTokensByIds` updates a single or several tokens. Returns a promise that can be awaited.
246
259
247
-
####autoLinkText
260
+
## autoLinkText
248
261
```javascript
249
262
dispatch.autoLinkText({
250
263
args: {
@@ -254,7 +267,7 @@ dispatch.autoLinkText({
254
267
```
255
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.
266
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.
267
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.
268
-
- 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"`
0 commit comments