Foundry VTT Notes #
A repo using Svelte to generate a static site for notes that connect Foundry VTT via the Foundry VTT REST API.
Setup #
- Install dependencies by running
npm install - Add your content in the form of Markdown files to the
contentfolder, and collect your notes into folders for each campaign (e.g.content/season-of-ghosts/session-33.md,content/curse-of-strahd/session-2.md, etc) - Create a
.envfile with the keys below in the Environment Variables section. - Run
npm run buildto build your site (at least once) - Run
npm run previewif you'd like to preview the site before publishing it.
Environment Variables #
Your .env file needs to contain the variable named PUBLIC_FOUNDRY_URL containing the URL (without http/https in front; e.g. PUBLIC_FOUNDRY_URL="foundryrestapi.com"). Then, for each campaign, you create an API key and store that in a variable labeled PUBLIC_[CAMPAIGN_SLUG]_KEY, where CAMPAIGN_SLUG is the slug you use for your campaign in the content folder (notably, it uses underscore separation instead of dash separation). Finally, create a variable labeled PUBLIC_CAMPAIGNS containing a comma-separated list of all of your campaign slugs.
Content Buttons #
To create a button in your Markdown file that uses the Foundry VTT REST API, at the top of your Markdown file, create a <script> section and import the components you'd like to use. Example:
<script>
import CheckButton from "$lib/components/checkButton.svelte";
import RollButton from "$lib/components/rollButton.svelte";
import RollTableButton from "$lib/components/rollTableButton.svelte";
</script>
Then, you would call each component like you would an HTML tag. The parameters required for each as well as examples on how to use them are listed below.
CheckButton #
<CheckButton skill="deception" dc=18 campaign="my-campaign-slug" />
- Usage: Sends a chat message to Foundry with a roll prompt for players to click on with their tokens
- Parameters:
- skill (required): the slug of the skill you'd like to use, all lowercase and separated by dashes. saves are included, check the information from your game system.
- dc (required): the Difficulty Class (DC) of the check you'd like to include.
- campaign (required): the campaign slug related an API key in your Environment Variables (see related section)
RollButton #
<RollButton dieFormula="1d4" flavor="Food Points" campaign="my-campaign-slug" label="Roll for Food" />
- Usage: Rolls a set of dice denoted in
dieFormulawith an optional flavor tag - Parameters:
- dieFormula (required): the dice formula you'd like to roll; compatible with mixed die types (e.g. 1d8 + 2d4).
- flavor: Flavor text to include in the roll
- campaign (required): the campaign slug related an API key in your Environment Variables (see related section)
- label: A label for the button
RollTableButton #
<RollTableButton uuid="mD4W0Ulq1tjgLYpz" label="Roll on the table" campaign="my-campaign-slug" />
- Usage: Roll on a RollTable in Foundry and whisper the result to the GM
- Parameters:
- uuid (required): The UUID of the RollTable
- label (required): The label for the button
- campaign (required): the campaign slug related an API key in your Environment Variables (see related section)
InfluenceStatblock and InfluenceThreshold #
<InfluenceStatblock id="npc-slug" campaign="my-campaign-slug">
<InfluenceThreshold value=2>
This is what happens when the party reaches 2 Influence Points with the NPC.
</InfluenceThreshold>
<InfluenceThreshold value=4>
This is what happens when the party reaches 4 Influence Points with the NPC.
</InfluenceThreshold>
</InfluenceStatblock>
- Usage: Display an Influence statblock for an NPC. Defined in a JSON file (see below).
- Parameters:
- InfluenceStatblock:
- id (required): The slug of the NPC. Must match a JSON file.
- campaign (required): the campaign slug related an API key in your Environment Variables (see related section)
- InfluenceThreshold:
- value (required): The value for the threshold
- InfluenceStatblock:
JSON File Requirements:
- name: The name of the NPC
- level: The level of the NPC
- traits: Any traits (e.g. humanoid) for the NPC
- type: The type line of the NPC (e.g. Female halfling wizard)
- perception: The NPC's Perception modifier
- will: The NPC's Will saving throw modifier
- rarity: The NPC's rarity (e.g. unique)
- size: The NPC's size (e.g. medium)
- discovery (array): The skills and DCs used for the Discovery action. Array of objects containing dc and skill values.
- influence (array): The skills and DCs used for the Influence action. See discovery.
- resistance: The resistances the NPC has.
- weakness: The weaknesses the NPC has.
- background: Information regarding the NPC's background.
- appearance: Information regarding the NPC's appearance.
- personality Information regarding the NPC's personality.
- penalty (optional): If the NPC has a penalty, list it here.
RevealTokenButton #
<RevealTokenButton sceneId="DXa0ozggIYKLvBQT" tokenId="M6Ol43ZTY2jOWvKi" campaign="my-campaign-slug" label="darkwood chest" />
- Usage: Make a token visible in Foundry
- Parameters:
- sceneId (required): The ID of the Scene that the Token is in
- tokenId (required): The ID of the Token to reveal. If you can't get the Token ID, you can open the console in Foundry with F12, and then type in
canvas.tokens.controlled[0].id - campaign (required): the campaign slug related an API key in your Environment Variables (see related section)
- label (required): The label for the button