Skip to content

Commit 63a0ebc

Browse files
authored
Merge pull request #55 from Roll20/story/SD-8484
story/SD-8484: Update with renaming of addActionsToHost to addMacrosToHost
2 parents 2266f02 + 681994e commit 63a0ebc

File tree

11 files changed

+222
-135
lines changed

11 files changed

+222
-135
lines changed
65.2 KB
Loading
61.6 KB
Loading
33.8 KB
Loading

content/docs/about/faq.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Roll buttons are HTML elements with specific attributes that execute designated
8989

9090
{{< details "Q: How are Custom Sheet attributes handled in Beacon?" >}}
9191

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.
9393
{{< /details >}}
9494

9595

@@ -105,9 +105,9 @@ Tokens represent characters or objects on Roll20 Tabletop (VTT). Functions like
105105
{{< /details >}}
106106

107107

108-
{{< details "Q: What is the role of the convertLegacyMacroAttributesArgs type?" >}}
108+
{{< details "Q: What is the role of the handleFallbackAttributesArgs type?" >}}
109109

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.
111111
{{< /details >}}
112112

113113

content/docs/about/glossary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ A digital or printed page used to track a character's attributes, abilities, and
3232
## Computed Property:
3333
Properties that have both get and set methods, which can be dynamically calculated.
3434

35-
## ConvertLegacyMacroAttributes:
35+
## HandleFallbackAttributes:
3636
A function to handle mapping Custom Sheet macro attributes to the new Beacon Sheet format.
3737

3838
## Dispatch:

content/docs/components/InitRelay.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ These components are crucial for handling actions, computations, macros, and rol
6767
target="_blank"
6868
>}}
6969
{{< 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."
72-
href="/beacon-docs/docs/components/custom-sheet-macro-attributes/"
70+
title="Fallbacks"
71+
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."
72+
href="/beacon-docs/docs/components/fallbacks/"
7373
target="_blank"
7474
>}}
7575
{{< /card-grid >}}

content/docs/components/actions.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,37 @@ The action's `method` receives a `props` object from the host containing the fol
5353
- `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.
5454
- `rolls` (optional): Included when action is triggered from a chat button. Contains the roll results of the original roll.
5555
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:
63+
64+
```javascript
65+
dispatch.addMacrosToHost({
66+
macro: {
67+
id: 'npc_strength_check1',
68+
name: npc_strength_check,
69+
characterId: '20kdk1-k3j',
70+
commandString?: `@{20kdk1-k3j|targeted_strength_check}`,
71+
locations: ['tokenActionBar']
72+
}
73+
})
74+
```
75+
76+
![targeted_strength_check](images/addMacroToHost_npc_example.png)
77+
78+
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:
89+
![targeted_strength_check](images/addMacroToHost_npc_example02.png)

content/docs/components/dispatch.md

Lines changed: 57 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Join to get access to the Beacon SDK, the community sheet repo for Beacon sheet,
2424

2525
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.
2626

27-
#### update
27+
## update
2828
```javascript
2929
dispatch.update({
3030
options: { overwrite?: boolean }
@@ -35,7 +35,7 @@ The `update` method sends character changes to the host (Roll20 Tabletop or Roll
3535

3636
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.
3737

38-
#### updateCharacter
38+
## updateCharacter
3939
```javascript
4040
dispatch.updateCharacter({
4141
character: Partial<Character>
@@ -45,7 +45,7 @@ Like the `update` method, `updateCharacter` sends character changes to the host
4545

4646
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.
4747

48-
#### roll
48+
## roll
4949
```javascript
5050
dispatch.roll({
5151
rolls: { [rollName: string]: string } // Ex. {attack: '1d20+4', damage: `3d6+2`}
@@ -58,7 +58,7 @@ If messageId is omitted, the roll will be associated with a new chat message and
5858

5959
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.
6060

61-
#### post
61+
## post
6262
```javascript
6363
dispatch.post({
6464
characterId: string,
@@ -78,7 +78,7 @@ The secret option is ignored unless whisper is also set, toggling to true will c
7878

7979
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.
8080

81-
#### query
81+
## query
8282
```javascript
8383
dispatch.query(options: Swal2Options): {
8484
isConfirmed: boolean,
@@ -102,7 +102,7 @@ The `query` method takes an options object and uses them to display a [SweetAler
102102

103103
`titleText, text, iconColor, input, width, padding, background, position, grow, timer, timerProgressBar, showConfirmButton, showDenyButton, showCancelButton, ariaLabel, confirmButtonText, denyButtonText, cancelButtonText, confirmButtonAriaLabel, confirmButtonColor, cancelButtonAriaLabel, cancelButtonColor, denyButtonAriaLabel, denyButtonColor, reverseButtons, showCloseButton, closeButtonAriaLabel, returnInputValueOnDeny, imageUrl, imageWidth, imageHeight, imageAlt, inputLabel, inputPlaceholder, inputValue, inputOptions, inputPlaceholder, inputAutoTrim, inputAttributes, validationMessage, progressSteps, currentProgressStep, progressStepsDistance.`
104104

105-
#### Perform
105+
## Perform
106106
```javascript
107107
dispatch.perform({
108108
characterId: string,
@@ -112,7 +112,7 @@ dispatch.perform({
112112
```
113113
`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.
114114

115-
#### getComputed
115+
## getComputed
116116
```javascript
117117
dispatch.getComputed({
118118
characterId: string,
@@ -132,7 +132,7 @@ dispatch.setComputed({
132132
```
133133
`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.
134134

135-
#### compendiumRequest
135+
## compendiumRequest
136136
```javascript
137137
dispatch.compendiumRequest({
138138
query: string
@@ -144,7 +144,7 @@ dispatch.compendiumRequest({
144144
```
145145
`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.
146146

147-
#### debouncedCompendiumRequest
147+
## debouncedCompendiumRequest
148148
```javascript
149149
dispatch.debouncedCompendiumRequest({
150150
query: string
@@ -154,7 +154,7 @@ dispatch.debouncedCompendiumRequest({
154154
```
155155
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.
156156

157-
#### getTokens
157+
## getTokens
158158
```javascript
159159
dispatch.getTokens({
160160
characterId: string
@@ -168,7 +168,7 @@ dispatch.getTokens({
168168
```
169169
`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.
170170

171-
#### addToTracker
171+
## addToTracker
172172
```javascript
173173
dispatch.addToTracker({
174174
tokenId?: string,
@@ -182,36 +182,49 @@ dispatch.addToTracker({
182182
```
183183
`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.
184184

185-
#### addActionsToHost
185+
## addMacrosToHost
186186
```javascript
187-
dispatch.addActionsToHost({
188-
sheetAction?: {
189-
characterId: string
190-
action: string
187+
dispatch.addMacrosToHost({
188+
macro: {
189+
id?: string
190+
name?: string
191+
characterId?: string
192+
commandString?: string
191193
args?: string[]
194+
locations?: ['macroBar'] | ['tokenActionBar'] | ['macroBar', 'tokenActionBar']
192195
}
193-
action?: string
194-
locations?: ['macroBar'] | ['tokenActionBar'] | ['macroBar', 'tokenActionBar']
195-
actionId?: string
196-
name: string
197196
requestId?: string
198197
}): void
199198
```
200-
`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.
201204

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
203210
```javascript
204-
dispatch.getActions({
211+
dispatch.getCharacterMacros({
205212
args: {
206-
characterId?: string
213+
characterId: string
207214
}
208215
}): 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+
} }
210223
}>
211224
```
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.
213226

214-
#### setContainerSize
227+
## setContainerSize
215228
```javascript
216229
dispatch.setContainerSize({
217230
args: {
@@ -222,7 +235,7 @@ dispatch.setContainerSize({
222235
```
223236
`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.
224237

225-
#### updateTokensByCharacter
238+
## updateTokensByCharacter
226239
```javascript
227240
dispatch.updateTokensByCharacter({
228241
args: {
@@ -233,7 +246,7 @@ dispatch.updateTokensByCharacter({
233246
```
234247
`updateTokensByCharacter` updates a particular character’s default token as well as all existing tokens representing that character. Returns a promise that can be awaited.
235248

236-
#### updateTokensByIds
249+
## updateTokensByIds
237250
```javascript
238251
dispatch.updateTokensByIds({
239252
args: {
@@ -244,7 +257,7 @@ dispatch.updateTokensByIds({
244257
```
245258
`updateTokensByIds` updates a single or several tokens. Returns a promise that can be awaited.
246259

247-
#### autoLinkText
260+
## autoLinkText
248261
```javascript
249262
dispatch.autoLinkText({
250263
args: {
@@ -254,7 +267,7 @@ dispatch.autoLinkText({
254267
```
255268
`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>`.
256269

257-
#### openDialogFromLink
270+
## openDialogFromLink
258271
```javascript
259272
dispatch.openDialogFromLink({
260273
args: {
@@ -265,4 +278,16 @@ dispatch.openDialogFromLink({
265278
`openDialogFromLink` opens the supplied urlString through the Roll20 Tabletop.
266279
- 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.
267280
- 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"`
292+
293+
![writeToClipboard_dialog](images/writeToClipboard_dialog.png)

0 commit comments

Comments
 (0)