Latest version | 10.0.5.2 |
---|---|
Minimum Core | 10 |
Compatible Core | 9 |
Last updated | 2 months ago |
Created | 8 months ago |
Authors |
|
Languages |
English |
Systems | All systems |
Project source | Project URL |
This is a system-agnostic module that a GM can use with the built-in methods to create chat cards with buttons for players (or the GM) to click.
The main method is Requestor.request()
, whose inner object requires at least an array of objects buttonData
. Example (for dnd5e
):
await Requestor.request({
description: "This is a request.",
buttonData: [{
label: "Nature Skill Check",
action: async () => {
await actor?.rollSkill("nat", {event});
}
}]
});
which will display a message with a button that anyone can click and be prompted to roll a Nature check. Th buttonData
array can take an arbitrary number of objects.
Create the following constants, all of which are optional, then run the main method with the given keys and values:
img
: the image to use in the card (defaults to "icons/containers/boxes/box-gift-green.webp"). Set this to 'false' to not display one at all.title
: the title to use in the card (defaults to 'Request').description
: the text description in the card (defaults to an empty string).buttonData
: an array of objects, detailed below.context
: an object used to pop out the message for all users; use popout: true
to create a popout, and autoClose: true
to close the popout after any click on a button. Other values include scale
(default 1.25), left
(default middle of the window), and top
(default 100).limit
: the limit of the buttons that do not have their own set limit. The values are Requestor.LIMIT.FREE
(for buttons that can be clicked as much as a user would want), .ONCE
(for a button that can be clicked only once), and .OPTION
(for buttons that can be clicked only once, and also disables all other buttons on the card set to .OPTION
).whisper
array, sound
file (string), and speaker
object.buttonData
arrayThe buttonData
array is an array of objects detailing the buttons that go on the card. Each object should have an action
(an arrow function) and a label
(a string). Any special parameters that should be used in the function but are unavailable due to scope can be passed in the object as well and referenced with prefixing this.
.
You can style the chat card by creating fake 'buttons' by passing one of these two types:
const buttonData = [
{type: Requestor.TYPE.DIV},
{type: Requestor.TYPE.TEXT, label: "Some descriptive text."}
];
These will be interpreted as a rule or descriptive text between the buttons. Good for grouping optional buttons together or adding a description beyond the base description passed to the card. The full list of keys (other than 'label' and 'action') to pass to a button include:
LIMIT
: FREE
, ONCE
, OPTION
(for an entry that can clicked any number of times, only once, or once between a group of options). Default: FREE
.TYPE
: BUTTON
, DIV
, TEXT
(for a button, a divider, or a short description). Default: BUTTON
.PERMISSION
: GM
, PLAYER
, ALL
(for an entry that will only be shown for GMs, only for players, or for all). Default: ALL
.Some helper functions are pre-defined:
Requestor.request
: the base function.Requestor.diceRoll({formula, flavor})
: a request for a player to roll a set of dice. Takes a formula and optional flavor text (strings). This example requests users to roll 2d4 + 2 with the flavor text "Healing Potion".await Requestor.diceRoll({formula: "2d4+2", flavor: "Healing Potion"});
Requestor.grantItem({itemData})
: a request for an actor to claim an item or array of items. Requires an array of item data objects.Requestor.dnd5e.rollAbilitySave({ability, dc})
: a request for a saving throw. Requires a three-letter key for the type of save (string) and the DC (integer). This example requests users for a DC 15 Strength saving throw.
await Requestor.dnd5e.rollAbilitySave({ability: "str", dc: 15});
Requestor.dnd5e.rollAbilityTest({ability})
: a request for an ability check. Requires a three-letter key for the type of ability check (string). This example requests users for an Intelligence check.
await Requestor.dnd5e.rollAbilityTest({ability: "int"});
Requestor.dnd5e.rollSkill({skill})
: a request for an ability check using a skill. Requires a three-letter key for the type of skill (string). This example requests users for a Persuasion check.
await Requestor.dnd5e.rollSkill({skill: "per"});
Requestor.dnd5e.useItem({itemName})
: a request for an actor to use one of their items. Requires the name of the item (string). This example requests users to use the item (or spell) they own with the name "Muffin":
await Requestor.dnd5e.useItem({itemName: "Muffin"});
Requestor.dnd5e.placeMeasuredTemplate({templateData})
: a request for a player to place a template. Requires template data (object). Do not pass a user to the template data.
Requestor.dnd5e.grantMuffin
: a request for an actor to be granted a muffin which restores 1d10 hit points when consumed.
These variables are declared in any scripts:
character
: the assigned character of the user executing the script.token
: the selected token of the user executing the script, or defaulting to the assigned character's active token on the current scene, if any.actor
: the actor of the selected token, if any, or defaulting to the assigned character.scene
: the current scene.this
: an object with all additional variables passed to the function.To install this package, open your Foundry Setup screen and navigate to your Module tab and click the Install Module button.
From there, you can either search for the package unique name: requestor or copy its manifest URL:
And paste it to the input box at the bottom of your window.
You can install this package directly to your Forge account.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Advertisement cookies are used to deliver visitors with customized advertisements based on the pages they visited before and analyze the effectiveness of the ad campaign.