### Module Manifest: Media Field Example Source: https://foundryvtt.com/article/module-development Illustrates the 'media' field in the module manifest, used to provide images for the setup screen, including type, URL, and thumbnail. ```json "media": [ { "type": "setup", "url": "modules/demon-queen-awakens/scenes/DemonQueenCover.webp", "thumbnail": "modules/demon-queen-awakens/scenes/thumbs/the-valley-of-stone.webp" } ] ``` -------------------------------- ### Example Manual Document Links Source: https://foundryvtt.com/article/journal These examples demonstrate how to apply the manual document linking syntax for Actors. ```foundryvtt @Actor[Locke] ``` ```foundryvtt @Actor[Pt1jPTgVWdJ6QYIA]{Locke} ``` -------------------------------- ### Initial Portable Installation Structure Source: https://foundryvtt.com/article/installation This illustrates the directory structure of a portable Foundry VTT installation before its first run. ```text E:\ FOUNDRYVTT-PORTABLE-12.345 App README.txt ``` -------------------------------- ### Quick-Start Adventure Registration Example Source: https://foundryvtt.com/article/adventure Example configuration for registering quick-start adventures in a module's module.json file. This allows new worlds to easily import your adventure. ```json "quickstart": { "adventures": {"dnd5e": uuid.of.the.5e.adventure, "pf2e": uuid.of.the.pf2e.adventure} "postImport": true, "world": { "background": "modules/your-modules-id/assets/background.webp", "cover": "modules/your-modules-id/assets/thumb.webp" } } ``` -------------------------------- ### Example Complete Module File Structure Source: https://foundryvtt.com/article/module-development An example of a more complex module file structure that includes additional assets like artwork and specific content files. ```text {userData}/Data/modules/ dice-tray/ module.json artwork/ d4-icon.png d6-icon.png d8-icon.png d10-icon.png d12-icon.png d20-icon.png templates/ dice-roller.html scripts/ roller.js styles/ roller.css packs/ rolltables lang/ en.json ``` -------------------------------- ### Example module.json Configuration Source: https://foundryvtt.com/article/publisher-handbook This is a minimal example of a module.json manifest file required for the Premium Content System. Ensure 'manifest' points to your package's public URL, 'protected' is set to true, and the 'download' field is omitted. ```json { "id": "your-modules-name", "title": "Your Module's Name", "manifest": "https://r2.foundryvtt.com/packages-public/your-modules-name/module.json", "protected": true } ``` -------------------------------- ### V10 Manifest: Example - Compatible V9 to V10 Source: https://foundryvtt.com/article/manifest-migration-guide Example showing how to specify compatibility from V9 to V10, including older V9 fields and the new V10 compatibility object. ```json { "minimumCoreVersion": 9, // V9 compatible minimum field "compatibleCoreVersion": "10.120", // V9 compatible verified field "compatibility": { "minimum": 9, // Can't be installed before V9 "verified": "10.120", // Verified compatible up to build 10.120 "maximum": 10 // Can't be installed after V10 } } ``` -------------------------------- ### Example UUID Document Link Source: https://foundryvtt.com/article/journal This example shows how to use the UUID syntax to link to a specific Actor. ```foundryvtt @UUID[Actor.VXbvLWzJkGYkMc63]{Akra (Dragonborn Cleric)} ``` -------------------------------- ### Example Item Creation and System Field Source: https://foundryvtt.com/article/system-development Demonstrates the structure of a created item, highlighting the 'system' field and its contents. ```json { "_id": "e6c7US1VK2cqejVJ", "name": "Test Weapon", "permission": { "default": 0 }, "system": { "rarity": "common", "damage": 5 }, "flags": {}, "type": "weapon", "img": "icons/svg/sword.svg" } ``` -------------------------------- ### Install Apache on Ubuntu or Debian Source: https://foundryvtt.com/article/apache Installs the Apache web server on Ubuntu or Debian-based Linux distributions. ```bash sudo apt install apache2 ``` -------------------------------- ### V10 Manifest: Example - Compatible V10 to V11 Source: https://foundryvtt.com/article/manifest-migration-guide Example of a V10 manifest specifying compatibility from V10 up to V11, with verification up to a specific build. ```json { "compatibility": { "minimum": 10, // Can't be installed before V10 "verified": "10.120", // Verified compatible up to build 10.120 "maximum": 11 // Can't be installed after V11 } } ``` -------------------------------- ### Install Certbot on Fedora Linux Source: https://foundryvtt.com/article/ssl Install Certbot on Fedora Linux distributions using dnf. ```bash sudo dnf install certbot ``` -------------------------------- ### Install Homebrew Package Manager (macOS) Source: https://foundryvtt.com/article/ssl Install Homebrew on macOS to manage packages. This is a prerequisite for installing Certbot. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Minimal module.json Manifest Example Source: https://foundryvtt.com/article/module-development This is a basic example of a module.json file. It includes the essential fields required for Foundry VTT to recognize and display your module. ```json { "id": "dice-tray", "title": "Dice Tray - An Example FVTT Module", "description": "A simple module created as a demo for working in the Foundry Virtual Tabletop framework.", "authors": [ { "name": "Atropos" } ], "version": "1.0.0", "compatibility": { "minimum": "10", "verified": "11" } } ``` -------------------------------- ### V10 Manifest: Example - Compatible with only V10 Source: https://foundryvtt.com/article/manifest-migration-guide Example of a V10 manifest specifying compatibility strictly within V10. ```json { "compatibility": { "minimum": 10, // Can't be installed before V10 "verified": 10, // Verified compatible with all of V10 "maximum": 10 // Can't be installed after V10 } } ``` -------------------------------- ### Create Application and User Data Directories Source: https://foundryvtt.com/article/installation Create the necessary directories for Foundry VTT application and user data. This is a prerequisite for installation. ```bash cd $HOME mkdir foundryvtt mkdir foundrydata ``` -------------------------------- ### Install Certbot on Debian-based Linux Source: https://foundryvtt.com/article/ssl Install Certbot on Debian-based Linux distributions using apt. ```bash sudo apt install certbot ``` -------------------------------- ### Configure Demo Mode with a JSON file Source: https://foundryvtt.com/article/configuration Example of a separate JSON configuration file for demo mode, specifying world name, source zip, and reset interval. ```json { "worldName": "pathfinder-demo", "sourceZip": "pathfinder-demo.zip", "resetSeconds": 3600, } ``` -------------------------------- ### Example Full V10+ Manifest Source: https://foundryvtt.com/article/manifest-migration-guide This is a comprehensive example of a manifest file structured for Foundry VTT version 10 and later. It includes all necessary fields for package identification, compatibility, authors, relationships with systems and modules, script and style paths, languages, and distribution URLs. ```json { "id": "vue-encounter-builder", "title": "🌑 Dungeon Moon Encounter Builder", "description": "A fair encounterൺ builder for Foundry", "version": "1.0.0", "compatibility": { "minimum": 10, "verified": 10.120, "maximum": 10 }, "authors": [ { "name": "Cody Swendrowski", "url": "https://swendrowski.us", "email": "cody@swendrowski.us", "discord": "cswendrowski#9701" } ], "relationships": { "systems": [ { "id": "toolkit13", "manifest": "https://github.com/Mageflame/Toolkit13/releases/download/latest/system.json", "compatibility": { "minimum": "1.11.0", "verified": "1.14.0", "maximum": "1.15.0" } } ], "requires": [ { "id": "dlopen", "type": "module", "manifest": "https://raw.githubusercontent.com/ForgeVTT/fvtt-module-dlopen/master/module.json", "compatibility": { "minimum": "1.2.0", "verified": "1.4.0", "maximum": "2.0.0" } }, { "id": "vueport", "type": "module", "manifest": "https://raw.githubusercontent.com/ForgeVTT/fvtt-module-vueport/master/module.json" } ] }, "esmodules": [ "/scripts/dugeonmoon.js" ], "styles": [ "/css/dugeonmoon.css" ], "languages": [ { "lang": "en", "name": "English", "path": "languages/en.json" } ], "url": "https://github.com/cswendrowski/FoundryVTT-Encounter-Builder", "manifest": "https://github.com/cswendrowski/FoundryVTT-Encounter-Builder/releases/latest/module.json", "download": "https://github.com/cswendrowski/FoundryVTT-Encounter-Builder/releases/download/1.0.0/module.zip" } ``` -------------------------------- ### Install Certbot on Arch-based Linux Source: https://foundryvtt.com/article/ssl Install Certbot on Arch-based Linux distributions using pacman. ```bash sudo pacman -S certbot ``` -------------------------------- ### Example Foundry VTT Usage Data Source: https://foundryvtt.com/article/privacy-policy This JSON object represents a real example of the usage data collected by the Foundry Virtual Tabletop software when the 'Share Usage Data' setting is enabled. It includes details about the operating system, Foundry VTT version, installed modules, game systems, and playtime. ```json { "timestamp": 1677769428480, "os": { "platform": "win32", "version": "Windows 10 Pro", "node": "18.13.0" }, "foundry": { "generation": 11, "build": 292, "channel": "prototype", "hosting": null }, "modules": { "atropos-maps": { "version": "1.4.0" }, "caeora-maps-tokens-assets": { "version": "2.1.3" }, "demon-queen-awakens": { "version": "1.1.1" }, "dice-so-nice": { "version": "4.6.5" }, "gameboard-support": { "version": "1.0.5" }, "house-divided": { "version": "1.1.2" }, "michaelghelfi": { "version": "1.3" }, "pf2e-abomination-vaults": { "version": "1.2.0" }, "pf2e-beginner-box": { "version": "2.2.0" }, "token-action-hud-core": { "version": "1.2.3" }, "token-action-hud-dnd5e": { "version": "1.2.2" }, "touch-vtt": { "version": "1.9.1" }, "trs-housedivided-dice-set": { "version": "1.0.1" }, "trs-metal-rainbow": { "version": "1.0.0" } }, "systems": { "dnd5e": { "version": "2.1.5", "playtime": 25306 }, "pf2e": { "version": "4.7.2" }, "worldbuilding": { "version": "0.7.2", "playtime": 0 } }, "worlds": {}, "playtime": { "total": 129731, "max": 104425 } } ``` -------------------------------- ### Install Node.js for Red Hat / Amazon Linux Source: https://foundryvtt.com/article/installation Installs Node.js version 20.x using the package manager for Red Hat-based Linux distributions. Ensure Node.js 20.18 or later is installed for compatibility. ```bash sudo yum install -y openssl-devel curl --silent --location https://rpm.nodesource.com/setup_20.x | sudo bash - sudo yum install -y nodejs ``` -------------------------------- ### Install Apache on Red Hat or CentOS Source: https://foundryvtt.com/article/apache Installs the Apache HTTP Server on Red Hat Enterprise Linux or CentOS. ```bash sudo yum update -y sudo yum -y install httpd ``` -------------------------------- ### Install Nginx on Ubuntu or Debian Source: https://foundryvtt.com/article/nginx Use these commands to update your package list and install Nginx on Ubuntu or Debian-based systems. ```bash sudo apt-get update sudo apt-get install nginx ``` -------------------------------- ### Launch Foundry via Node.js Source: https://foundryvtt.com/article/configuration Example of launching Foundry VTT using Node.js with specified port, world, and data path. ```bash node main.js --port=30000 --world=my-world --dataPath=/local/data/foundryvtt ``` -------------------------------- ### Launch Foundry via Electron (Windows) Source: https://foundryvtt.com/article/configuration Example of launching the packaged Foundry VTT executable on Windows with specified port, world, and data path. ```bash FoundryVTT.exe --port=30000 --world=my-world --dataPath=D:\FoundryVTT ``` -------------------------------- ### Start Foundry VTT Server (Windows V12 and before) Source: https://foundryvtt.com/article/installation Use this command to start the Foundry VTT server on Windows for versions V12 and older. Specify the data path using the --dataPath argument. ```bash node resources/app/main.js --dataPath=%userprofile%/foundrydata ``` -------------------------------- ### Portable Installation Structure After First Run Source: https://foundryvtt.com/article/installation This shows the directory structure of a portable Foundry VTT installation after it has been run for the first time, including the automatically created Config, Data, and Logs folders. ```text E:\ FOUNDRYVTT-PORTABLE-12.345 App Config Data Logs README.txt ``` -------------------------------- ### Install Nginx on Red Hat or CentOS Source: https://foundryvtt.com/article/nginx Execute these commands to update your system and install Nginx on Red Hat or CentOS systems. ```bash sudo yum update -y sudo yum install nginx ``` -------------------------------- ### Install Caddy on Ubuntu/Debian Source: https://foundryvtt.com/article/caddy Installs Caddy stable version on Ubuntu or Debian-based systems using apt package manager. ```bash $ sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https $ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg $ curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list $ sudo apt update $ sudo apt install caddy ``` -------------------------------- ### Install Foundry VTT Software Source: https://foundryvtt.com/article/installation Download and unzip the Foundry VTT software into the application directory. Ensure you replace the placeholder URL with the actual download link. ```bash cd foundryvtt wget -O foundryvtt.zip "" unzip foundryvtt.zip ``` -------------------------------- ### Install Certbot using Homebrew (macOS) Source: https://foundryvtt.com/article/ssl Install the latest version of Certbot on macOS using the Homebrew package manager. ```bash brew install certbot ``` -------------------------------- ### Calendar Versioning (CalVer) Examples Source: https://foundryvtt.com/article/intro-development Demonstrates date-based versioning using CalVer. Recommended for user-facing packages. Note: Pre-release notation (+/-) is not supported. ```text 2022-01-01 -> 2022-02-20 -> 2022-03-12 220101 -> 20220220 -> 20220312 ``` -------------------------------- ### Launch Foundry via Electron (Linux) Source: https://foundryvtt.com/article/configuration Example of launching the packaged Foundry VTT executable on Linux with specified port, world, and data path. ```bash foundryvtt --port=30000 --world=my-world --dataPath=/local/data/foundryvtt ``` -------------------------------- ### Incrementing Version Examples Source: https://foundryvtt.com/article/intro-development Illustrates simple version increments. Suitable for user-facing packages like content and modules. ```text 1 -> 2 -> 3 1.1 -> 1.2 -> 2.0 alpha1 -> alpha2 -> beta1 -> stable1 ``` -------------------------------- ### Semantic Versioning (Semver) Examples Source: https://foundryvtt.com/article/intro-development Shows the common Major.Minor.Patch format for Semver. Recommended for libraries, game systems, or CLI tools. Note: Pre-release notation (+/-) is not supported. ```text 1.0.0 -> 1.0.1 -> 1.1.0 -> 2.0.0 ``` -------------------------------- ### Install Nginx on Amazon Linux 2 Source: https://foundryvtt.com/article/nginx Run these commands to update your system and install Nginx version 1 on Amazon Linux 2. ```bash sudo yum update -y sudo amazon-linux-extras install nginx1 -y ``` -------------------------------- ### Install Node.js for Debian / Ubuntu Source: https://foundryvtt.com/article/installation Installs Node.js version 20.x using the package manager for Debian-based Linux distributions. Node.js 20.18 or later is recommended for Foundry VTT. ```bash sudo apt install -y libssl-dev curl -sL https://deb.nodesource.com/setup_20.x | sudo bash - sudo apt install -y nodejs ``` -------------------------------- ### Compendium Pack Entry Example Source: https://foundryvtt.com/article/packaging-guide An example of a compendium pack entry within the module.json file. This defines the name, label, path, and type for a compendium pack. ```json { "name": "module-creatures", "label": "Module Creatures", "path": "./packs/creatures.db", "type": "Actor" } ``` -------------------------------- ### Basic "Hello World" JavaScript Module Script Source: https://foundryvtt.com/article/module-development A simple JavaScript example demonstrating immediate execution, initialization hook, and ready hook. Use the browser's developer console to observe the log messages. ```javascript console.log("Hello World! This code runs immediately when the file is loaded."); Hooks.on("init", function() { console.log("This code runs once the Foundry VTT software begins its initialization workflow."); }); Hooks.on("ready", function() { console.log("This code runs once core initialization is ready and game data is available."); }); ``` -------------------------------- ### Configure and Run Node Process on macOS Source: https://foundryvtt.com/article/installation Set up and run the Foundry VTT server using Node.js on macOS. This includes creating the data directory and navigating to the installation folder. ```bash # create a user data directory cd $HOME mkdir foundrydata # Go to the location where you installed the Node version of the Foundry VTT software cd ~/FoundryVTT_Node # Start running the server (FoundryVTT V13 and newer) node main.js --dataPath=$HOME/foundrydata ``` -------------------------------- ### Start Foundry VTT Server (V13+) Source: https://foundryvtt.com/article/installation Run the Foundry VTT server using Node.js for versions V13 and newer. Specify the data path for user data. ```bash node main.js --dataPath=$HOME/foundrydata ``` -------------------------------- ### Linux Installation Archive Extraction Source: https://foundryvtt.com/article/installation Use this command to extract the Foundry VTT zip archive to your home directory on Linux. Ensure you have unzip installed. ```bash unzip foundryvtt.zip -d $HOME/foundryvtt ``` -------------------------------- ### Manage Apache Service on Ubuntu/Debian Source: https://foundryvtt.com/article/apache Commands to start, stop, and restart the Apache web server on Ubuntu and Debian systems using systemctl. ```bash # For Ubuntu and Debian sudo systemctl start apache2 sudo systemctl stop apache2 sudo systemctl restart apache2 ``` -------------------------------- ### Example System File Structure Source: https://foundryvtt.com/article/system-development A standard file structure for a minimal Foundry VTT game system module. This includes the required system.json and other common directories for code, styles, data, and localization. ```text {userData}/Data/systems/mysystem/ system.json mysystem.mjs module/ data-models.mjs documents.mjs styles/ system-styles.css packs/ monsters/ items/ lang/ en.json ``` -------------------------------- ### Example Roll with Description Source: https://foundryvtt.com/article/dice Demonstrates rolling a d20, adding 2, and including descriptive text for the roll. ```foundryvtt /r 1d20 + 2 # This is my roll! ``` -------------------------------- ### V9 Manifest: Name Field Source: https://foundryvtt.com/article/manifest-migration-guide Example of the 'name' field in a V9 manifest. ```json { "name": "1000-fish", "title": "1000 Fish" } ``` -------------------------------- ### Example: Roll Five Twenty-Sided Dice Source: https://foundryvtt.com/article/dice This example rolls five twenty-sided dice and outputs the sum. Comments can be included to describe the roll. ```text /r 5d20 #Rolls five twenty-sided dice, generating random numbers from 1 to 20, and outputting the sum of all rolls. ``` -------------------------------- ### Find Modifiable Traits for Player Character (dnd5e Example) Source: https://foundryvtt.com/article/active-effects This specific example shows how to find modifiable traits for a player character in the dnd5e system, useful for creating active effects. ```javascript Object.keys(foundry.utils.flattenObject(game.system.model.Actor.character)) ``` -------------------------------- ### Start Foundry VTT Server (V12 and older) Source: https://foundryvtt.com/article/installation Run the Foundry VTT server using Node.js for versions V12 and older. This command differs from newer versions in its path to the main executable. ```bash node resources/app/main.js --dataPath=$HOME/foundrydata ``` -------------------------------- ### Install Caddy on CentOS 7 Source: https://foundryvtt.com/article/caddy Installs Caddy on Red Hat or CentOS 7 using yum package manager and enabling the Caddy copr repository. ```bash $ yum install yum-plugin-copr $ yum copr enable @caddy/caddy $ yum install caddy ``` -------------------------------- ### Hot Reload Configuration in Package Manifest Source: https://foundryvtt.com/article/configuration Example of specifying hot-reload paths within a package's manifest file. ```json { "flags": { "hotReload": { "paths": [] } } } ``` -------------------------------- ### Install Caddy on Fedora/CentOS 8 Source: https://foundryvtt.com/article/caddy Installs Caddy on Fedora, Red Hat, or CentOS 8 using dnf package manager and enabling the Caddy copr repository. ```bash $ dnf install 'dnf-command(copr)' $ dnf copr enable @caddy/caddy $ dnf install caddy ``` -------------------------------- ### Manage Caddy Service Source: https://foundryvtt.com/article/caddy Use these commands to check the status, start, stop, or restart the Caddy service. ```bash # Check Status sudo service caddy status # Start Caddy sudo service caddy start # Stop Caddy sudo service caddy stop # Restart Caddy sudo service caddy restart ``` -------------------------------- ### Launch Foundry VTT Server (Windows V13+) Source: https://foundryvtt.com/article/installation Launch the Node.js server for Foundry VTT V13 and newer on Windows. Ensure you are in the installation directory and specify the data path. ```bash cd C:\\Program Files\\FoundryVTT/ node main.js --dataPath=%userprofile%/foundrydata ``` -------------------------------- ### Legacy ActiveEffect Transferral Example Source: https://foundryvtt.com/article/v11-active-effects Demonstrates creating an ActiveEffect with `transfer: true` when `CONFIG.ActiveEffect.legacyTransferral` is true. The effect is transferred to the actor and its origin points to the item. ```javascript CONFIG.ActiveEffect.legacyTransferral = true; await ActiveEffect.implementation.create({ name: 'Name Change', transfer: true, changes: [{ key: 'name', value: 'Other Name', mode: CONST.ACTIVE_EFFECT_MODES.OVERRIDE }] }, { parent: item }); await Item.create(item.toObject(), { parent: actor }); // Verify the Actor's name has been changed. console.log(actor.name); // "Other Name" // A new ActiveEffect has been created on the Actor now, with its origin pointing to the Item. actor.effects.getName('Name Change'); ``` -------------------------------- ### Manage Apache Service on Amazon Linux/RHEL/CentOS Source: https://foundryvtt.com/article/apache Commands to start, stop, and restart the Apache HTTP Server on Amazon Linux, RHEL, or CentOS systems using systemctl. ```bash # For Amazon Linux, RHEL, or CentOS sudo systemctl start httpd sudo systemctl stop httpd sudo systemctl restart httpd ``` -------------------------------- ### Immediate Inline Roll Example Source: https://foundryvtt.com/article/dice Use this for simple rolls within descriptive text. The result is immediately shown in the chat message. ```foundryvtt The boulders drop onto the player character, dealing [[2d12]] bludgeoning damage. ``` -------------------------------- ### Bulk Token Updates using Delta (v11) Source: https://foundryvtt.com/article/v11-actor-delta For bulk operations like system migrations, updating the `delta` property on multiple tokens is more efficient than individual actor updates. This example demonstrates preparing updates for multiple tokens. ```javascript const updates = scene.tokens.map(token => { return { _id: token.id, delta: { name: 'Furious Hobgoblin' } }; }); scene.updateEmbeddedDocuments('Token', updates); ``` -------------------------------- ### Script Macro Example with Built-in Values Source: https://foundryvtt.com/article/macros This script macro logs the selected token and actor to the console and then creates a chat message. It's most useful when a single token is selected. Ensure a token is selected before execution. ```javascript //token and actor do not need to be defined. console.log("Selected token and actor:"); console.log(token); console.log(actor); let msg_html = token ? `

Hey there!

Hi, I'm ${actor.name}!

` : "Please select a token before using the Hey There macro."; ChatMessage.create({ user: game.user._id, speaker: ChatMessage.getSpeaker({token: actor}), content: msg_html }); ``` -------------------------------- ### Compendium Pack Definition - Version 11 (After) Source: https://foundryvtt.com/article/v11-leveldb-packs Example of a compendium pack definition in module.json or system.json for Foundry VTT Version 11 and newer, referencing the new folder format. ```json { "packs": [{ "name": "monsters", "label": "Monsters", "system": "some-system", "type": "Actor", "path": "packs/monsters" }] } ``` -------------------------------- ### Configure Trackable Actor Attributes Source: https://foundryvtt.com/article/system-development Configures which actor attributes are trackable by the core API for display as token bars or editable values. This example sets up resources for 'hero' and 'pawn' actors. ```javascript CONFIG.Actor.trackableAttributes = { hero: { bar: ["resources.health", "resources.power", "goodness"], value: ["level"] }, pawn: { bar: ["resources.health", "resources.power"], value: [] } }; ``` -------------------------------- ### Referencing a Map Image in Foundry VTT Source: https://foundryvtt.com/article/configuration This example shows how to reference a map image file located within the User Data directory using a web-accessible URL. The path is relative to the Data folder. ```text /Data/worlds/my-world/maps/dungeons/deadly-dungeon-01.jpg ``` ```text worlds/my-world/maps/dungeons/deadly-dungeon-01.jpg ``` -------------------------------- ### Get Item Data Paths Source: https://foundryvtt.com/article/active-effects This JavaScript snippet, when run in the Foundry VTT developer console, lists all available attribute keys for Items. It is essential for finding the correct 'system.' prefix paths when creating Active Effects for items. ```javascript const types = Item.implementation.TYPES; const shells = types.map( t => new Item.implementation({name: t, type: t})); shells.forEach( s => console.log(`'${s.type}'`, "type Items have the following attribute keys available:\nsystem.\n", s.toObject().system)); ``` -------------------------------- ### Victim Picker Script Macro Source: https://foundryvtt.com/article/macros Picks a random victim from six numbered players and logs the result to the console and chat. This is a basic example demonstrating direct API interaction. ```javascript //Pick a victim from one of six possible numbered players and export the results to chat and to the console log const roll = await new Roll(`1d6`).roll(); console.log(roll); const results_html = `

Victim Selected!

Something bad is going to happen to
Player ${roll.total}. Buckle up!

`; ChatMessage.create({ user: game.user._id, content: results_html }); ``` -------------------------------- ### AWS S3 Configuration JSON Source: https://foundryvtt.com/article/aws-s3 Example JSON configuration for AWS S3 integration. This includes bucket names, preferred region, and access credentials. Ensure sensitive credentials are handled securely. ```json { "buckets": ["your-bucket","your-other-bucket"], "region": "YOUR_PREFERRED_REGION", "credentials": { "accessKeyId": "YOUR_ACCESS_KEY_ID", "secretAccessKey": "YOUR_SECRET_ACCESS_KEY" } } ``` -------------------------------- ### Compendium Pack Definition - Version 10 (Before) Source: https://foundryvtt.com/article/v11-leveldb-packs Example of a compendium pack definition in module.json or system.json prior to Foundry VTT Version 11, using the old .db file format. ```json { "packs": [{ "name": "monsters", "label": "Monsters", "system": "some-system", "type": "Actor", "path": "packs/monsters.db" }] } ``` -------------------------------- ### Deferred Inline Roll Example Source: https://foundryvtt.com/article/dice Embeds a button in the chat message that, when clicked, executes the roll. Useful for rolls that multiple users might need to make. ```foundryvtt Can everyone roll a [[/roll 1d10]] for me? ``` -------------------------------- ### Get Actor Data Paths Source: https://foundryvtt.com/article/active-effects Use this JavaScript snippet in the Foundry VTT developer console to list all available attribute keys for Actors. This helps in identifying the correct 'system.' prefix paths for Active Effects. ```javascript const types = Actor.implementation.TYPES; const shells = types.map( t => new Actor.implementation({name: t, type: t})); shells.forEach( s => console.log(`'${s.type}'`, "type Actors have the following attribute keys available:\nsystem.\n", s.toObject().system)); ``` -------------------------------- ### Nginx Service Management Commands Source: https://foundryvtt.com/article/nginx Commands to manage the Nginx service, including enabling a new site configuration, testing the configuration file for syntax errors, starting, stopping, and restarting the Nginx server. ```bash # Enable new site sudo ln -s /etc/nginx/sites-available/your.hostname.com /etc/nginx/sites-enabled/ # Test your configuration file, please note that on some OS versions this may be "sudo service nginx configtest" instead sudo service nginx conftest # Start Nginx sudo service nginx start # Stop Nginx sudo service nginx stop # Restart Nginx sudo service nginx restart ``` -------------------------------- ### Foundry VTT Proxy Configuration Source: https://foundryvtt.com/article/caddy Sets Foundry Virtual Tabletop options to indicate it's running behind a proxy server on port 443. Adjust 'hostname' and 'routePrefix' as needed for your setup. ```json "hostname": "your.hostname.com", "routePrefix": null, "sslCert": null, "sslKey": null, "port": 30000, "proxyPort": 443, "proxySSL": true ``` -------------------------------- ### Configure Demo Mode in options.json Source: https://foundryvtt.com/article/configuration Configuration for demo mode within the options.json file, specifying world name, source zip, and reset interval. ```json { ..., "demo": { "worldName": "demo-world", "sourceZip": "demo-world.zip", "resetSeconds": 3600 }, ... } ``` -------------------------------- ### Create an Item Source: https://foundryvtt.com/article/system-development Demonstrates how to create a new item with specific properties. ```javascript const item = await Item.implemenation.create({ name: "Item", type: "weapon" }); console.log(item.system.price); // 20 console.log(item.isFree); // false ``` -------------------------------- ### System Entry Point Configuration Source: https://foundryvtt.com/article/system-development Configures custom Document implementations, System Data Models, and trackable attributes on system initialization. This is the main entry point for system code. ```javascript import { SystemActor, SystemItem } from "./module/documents.mjs"; import { HeroDataModel, VillainDataModel, PawnDataModel, WeaponDataModel, SpellDataModel } from "./module/data-models.mjs"; Hooks.once("init", () => { // Configure custom Document implementations. CONFIG.Actor.documentClass = SystemActor; CONFIG.Item.documentClass = SystemItem; // Configure System Data Models. CONFIG.Actor.dataModels = { hero: HeroDataModel, villain: VillainDataModel, pawn: PawnDataModel }; CONFIG.Item.dataModels = { weapon: WeaponDataModel, spell: SpellDataModel }; // Configure trackable attributes. CONFIG.Actor.trackableAttributes = { hero: { bar: ["resources.health", "resources.power", "goodness"], value: ["progress"] }, pawn: { bar: ["resources.health", "resources.power"], value: [] } }; }); ``` -------------------------------- ### Download Foundry VTT via Command Line Source: https://foundryvtt.com/article/installation Use this command with `wget` to download Foundry VTT using a timed URL. Ensure the URL is enclosed in double quotes. ```bash wget -O foundryvtt.zip "PASTED-URL-FROM-FOUNDRY-WEBSITE-HERE" ``` -------------------------------- ### Apache Reverse Proxy Configuration Source: https://foundryvtt.com/article/apache A sample Apache configuration file for setting up a reverse proxy for Foundry Virtual Tabletop. This configuration requires mod_proxy, mod_proxy_http, and mod_proxy_wstunnel. Adjust 'your.hostname.com' and paths as necessary. ```apache # Apache .conf for reverse proxy of Foundry Virtual Tabletop. # Requires mod_proxy mod_proxy_http mod_proxy_wstunnel for WebSocket support. # For Ubuntu and Debian this goes in /etc/apache2/apache2.conf # For Amazon Linux, CentOS, and RHEL this goes in /etc/httpd/conf/httpd.conf ServerName your.hostname.com # Proxy Server Configuration ProxyPreserveHost On ProxyPass "/socket.io/" "ws://localhost:30000/socket.io/" ProxyPass / http://localhost:30000/ ProxyPassReverse / http://localhost:30000/ # Increase the maximum upload limit Apache will allow LimitRequestBody 104857600 # 100MB upload ``` -------------------------------- ### V10 Manifest: ID Field Source: https://foundryvtt.com/article/manifest-migration-guide Example of the renamed 'id' field in a V10 manifest. ```json { "id": "1000-fish", "title": "1000 Fish" } ``` -------------------------------- ### Example: Roll 1d20 / 3 Source: https://foundryvtt.com/article/dice Rolls one twenty-sided die and divides the result by 3. ```text /roll 1d20 / 3 ``` -------------------------------- ### Create Foundry Data Folder (Windows) Source: https://foundryvtt.com/article/installation Create a directory to store Foundry VTT data on Windows. This command is run from your user profile directory. ```bash mkdir foundrydata ``` -------------------------------- ### Module Description Configuration Source: https://foundryvtt.com/article/packaging-guide Provide a detailed description of your module, which can include HTML for formatting. ```json "description": "A collection of my content." ``` -------------------------------- ### Configure SSL Certificate and Key in options.json Source: https://foundryvtt.com/article/ssl When using an existing SSL certificate and key, specify their filenames in the options.json file within your Foundry VTT configuration directory. Ensure the certificate and key files are also placed in this directory. ```json ... "sslCert": "localhost.cert", "sslKey": "localhost.key", ... ``` -------------------------------- ### Simple Dice Roll Macro Source: https://foundryvtt.com/article/macros Use this macro to perform a simple dice roll. It's a basic example of a chat macro. ```chat /r 1d6#which of my players is the next victim? ``` -------------------------------- ### Example: Roll 1d20 / 2 + 10 Source: https://foundryvtt.com/article/dice Rolls one twenty-sided die, divides the result by 2, and then adds 10 to the final number. ```text /roll 1d20 / 2 + 10 ``` -------------------------------- ### Configure Foundry VTT SSL Settings Source: https://foundryvtt.com/article/ssl Set the port to 443 and specify the SSL certificate and key files in Foundry VTT's configuration. ```text Port: 443 SSL Certificate: fullchain.pem SSL Key: privkey.pem ``` -------------------------------- ### V10 Package Manifest Structure with Relationships Source: https://foundryvtt.com/article/manifest-migration-guide Illustrates the V10 manifest structure using the 'relationships' field for systems and dependencies, including compatibility checks. ```json { "relationships": { "systems": [{ "id": "archmage", "type": "system", "manifest": "https://gitlab.com/asacolips-projects/foundry-mods/archmage/-/raw/1.5.0/system.json", "compatibility": { "verified": "1.5.0" } }], "requires": [{ "id": "_chatcommands", "type": "module", "manifest": "https://github.com/League-of-Foundry-Developers/Chat-Commands-Lib/releases/download/1.2.0/module.json", "compatibility": { "verified": "1.2.0" } }] } } ``` -------------------------------- ### Example: Roll 1d100 * 2 / 1d4 Source: https://foundryvtt.com/article/dice Rolls a one hundred-sided die, multiplies the result by 2, and then divides it by the result of rolling a four-sided die. ```text /roll 1d100 * 2 / 1d4 ``` -------------------------------- ### System Manifest Configuration (system.json) Source: https://foundryvtt.com/article/system-development This JSON file defines the essential properties and configurations for a Foundry VTT game system. It includes metadata, compatibility information, and definitions for document types, languages, and other system-specific settings. ```json { "id": "mysystem", "title": "Minimal World Building", "description": "A human-readable description of your system.", "version": "1.0.0", "compatibility": { "minimum": 12, "verified": 12 }, "authors": [ { "name": "me", "url": "YOUR WEBSITE ADDRESS HERE", "email": "YOUR EMAIL ADDRESS HERE", "discord": "YOUR DISCORD USERNAME HERE" } ], "esmodules": ["mysystem.mjs"], "styles": ["styles/system-styles.css"], "packs": [ { "name": "monsters", "label": "My Monsters", "type": "Actor" }, { "name": "items", "label": "My Items", "type": "Item" } ], "languages": [ { "lang": "en", "name": "English", "path": "lang/en.json" } ], "documentTypes": { "Actor": { "hero": { "htmlFields": ["background.biography"] }, "villain": { "htmlFields": ["background.biography"] }, "pawn": {} }, "Item": { "weapon": {}, "spell": {} } }, "socket": false, "initiative": "1d20", "grid": { "distance": 10, "units": "ft" }, "primaryTokenAttribute": "resources.health", "secondaryTokenAttribute": "resources.power", "url": "https://your/hosted/system/repo/", "manifest": "https://your/hosted/system/repo/system.json", "download": "https://your/packaged/download/archive.zip" } ``` -------------------------------- ### Module Manifest: Authors Field Example Source: https://foundryvtt.com/article/module-development Defines the 'authors' field in the module manifest, specifying author details like name, discord, email, and URL. ```json "authors": [ { "name": "Atropos", "discord": "Atropos#3814", "email": "admin@foundryvtt.com", "url": "https://foundryvtt.com" } ] ``` -------------------------------- ### Enable Uploads in Foundry VTT Folders Source: https://foundryvtt.com/article/asset-management Configure world, module, or system folders to allow uploads by setting the 'canUpload' flag to true in their respective JSON manifest files. If omitted, uploads are disallowed by default. ```json "flags": { "canUpload": true }, ``` -------------------------------- ### Example: Roll 1d10 + 1d4 + 4 Source: https://foundryvtt.com/article/dice Rolls one ten-sided die and adds the result to a single four-sided die roll, with an additional constant of 4. ```text /roll 1d10 + 1d4 + 4 ``` -------------------------------- ### Module Compatibility Settings Source: https://foundryvtt.com/article/module-development Define the minimum and maximum Foundry VTT versions your module is compatible with. 'verified' indicates the version it was tested against. ```json { "compatibility": { "minimum": 10, "verified": "11", "maximum": "11" } } ``` -------------------------------- ### Rounding Function for Dice Rolls Source: https://foundryvtt.com/article/dice-advanced Use the round function to get the result of a dice roll divided by a number, rounded to the nearest integer. ```foundryvtt /r round(1d12/3) ``` -------------------------------- ### Linux: Create Compressed Backup Archive Source: https://foundryvtt.com/article/user-data-backup This command creates a compressed tar archive of your Foundry VTT Data and Config folders. Ensure Foundry VTT is closed before running. ```bash tar -czvf foundry-backup.tar.gz Data Config ``` -------------------------------- ### V10 Manifest: Compatibility Object Source: https://foundryvtt.com/article/manifest-migration-guide Illustrates the new 'compatibility' object for specifying core version compatibility in V10. ```json { "compatibility": { "minimum": 9, "verified": "9.120" } } ``` -------------------------------- ### Ceiling Function for Dice Rolls Source: https://foundryvtt.com/article/dice-advanced Use the ceiling function to get the smallest integer greater than or equal to the result of a dice roll divided by a number. ```foundryvtt /r ceil(1d12/3) ``` -------------------------------- ### Floor Function for Dice Rolls Source: https://foundryvtt.com/article/dice-advanced Use the floor function to get the largest integer less than or equal to the result of a dice roll divided by a number. ```foundryvtt /r floor(1d12/3) ``` -------------------------------- ### Get Actor Roll Data Source: https://foundryvtt.com/article/dice-advanced Retrieve the rollable data for a specific actor using JavaScript in the Developer Tools console. This helps in understanding available data paths. ```javascript const actor = game.actors.getName("My Character Name"); console.log(actor.getRollData()); ``` -------------------------------- ### Module Compatibility Configuration Source: https://foundryvtt.com/article/packaging-guide Specify the minimum required Foundry Virtual Tabletop version for your module to function correctly. ```json "compatibility": {"minimum":"10"} ``` -------------------------------- ### Non-Legacy ActiveEffect Transferral Example Source: https://foundryvtt.com/article/v11-active-effects Demonstrates creating an ActiveEffect with `transfer: true` when `CONFIG.ActiveEffect.legacyTransferral` is false. The effect applies to the actor but is not transferred, and no effect is created on the actor's collection. ```javascript CONFIG.ActiveEffect.legacyTransferral = false; await ActiveEffect.implementation.create({ name: 'Name Change', transfer: true, changes: [{ key: 'name', value: 'Other Name', mode: CONST.ACTIVE_EFFECT_MODES.OVERRIDE }] }, { parent: item }); await Item.create(item.toObject(), { parent: actor }); // Verify the Actor's name has been changed. console.log(actor.name); // "Other Name" // No ActiveEffect created on the Actor. actor.effects.getName('Name Change'); // undefined ``` -------------------------------- ### Foundry VTT is AWESOME! Image Macro Source: https://foundryvtt.com/article/macros This chat macro displays an image using HTML. It includes an image tag with a specified source and width. ```chat

Foundry VTT is AWESOME!

``` -------------------------------- ### V9 Manifest: Compatibility Fields Source: https://foundryvtt.com/article/manifest-migration-guide Shows the older 'minimumCoreVersion' and 'compatibleCoreVersion' fields used for compatibility in V9. ```json { "minimumCoreVersion": 9, "compatibleCoreVersion": "9.120" } ``` -------------------------------- ### Create an Item Document Source: https://foundryvtt.com/article/system-development Demonstrates the creation of a new item document with a specified name and type. The internal data is automatically populated according to the defined Data Model schema. ```javascript const item = await Item.implementation.create({name: "Test Weapon", type: "weapon"}); console.log(item); // The created item data structure ``` -------------------------------- ### Example of Describing Individual Dice Source: https://foundryvtt.com/article/dice Rolls two six-sided dice tagged as 'slashing damage' and one eight-sided die tagged as 'fire damage'. ```foundryvtt /roll 2d6[slashing damage]+1d8[fire damage] ``` -------------------------------- ### Recommended Module Boilerplate Structure Source: https://foundryvtt.com/article/module-development A recommended directory structure for organizing common module assets. This includes directories for templates, scripts, styles, packs, and language files. ```text {userData}/Data/modules/ dice-tray/ module.json templates/ scripts/ styles/ packs/ lang/ ``` -------------------------------- ### Include Stylesheets Source: https://foundryvtt.com/article/system-development Lists CSS file paths to be included in the game session. Paths are relative to the system's root directory. ```json "styles": [] ``` -------------------------------- ### V10 Actor Data Update Example Source: https://foundryvtt.com/article/v11-actor-delta In V10 and earlier, direct updates to an actor's properties within a token's `actorData` were not treated as actor updates, requiring workarounds. ```javascript token.actor.update({ name: 'Furious Goblin' }); // Becomes: token.update({ actorData: { name: 'Furious Goblin' } }); ``` -------------------------------- ### Specify System Dependencies Source: https://foundryvtt.com/article/system-development Defines required modules, systems, or worlds. If only an ID is provided, Foundry VTT will attempt to discover details from its website. An explicit manifest URL can also be provided. ```json "relationships": { "requires": [{ "id": "_chatcommands", "manifest": "https://github.com/League-of-Foundry-Developers/Chat-Commands-Lib/releases/download/1.2.0/module.json", "compatibility": { "verified": "1.2.0" } }] } ``` -------------------------------- ### Manual Document Linking Syntax Source: https://foundryvtt.com/article/journal Use this syntax to manually create links to documents by their name or ID. Using the document ID is recommended for reliability. ```foundryvtt @DocumentType[Document Name] ``` ```foundryvtt @DocumentType[Document ID]{Custom Text Label} ```