### Image Command Line Examples Source: https://perchance.org/ai-character-chat-docs Examples of using the /image command with parameters. ```text /image a cute rabbit (resolution:::512x768) ``` ```text /image a cute rabbit (seed:::84756293) ``` -------------------------------- ### Full Implementation Example Source: https://perchance.org/consumable-list-loop-plugin A complete example showing the plugin usage within a generator output and the corresponding list definition. ```Perchance output There were a bunch of animals on the island including [a = consumableListLoop(animals)], [a], [a] ... animals frogs turtles birds ... ``` -------------------------------- ### Shortcut Command Examples Source: https://perchance.org/ai-character-chat-docs Examples of shortcut commands for AI character interactions. ```text /ai @Alice#1 write an interesting reply ``` ```text /ai @Bob#2 write a creative reply ``` ```text /ai @Bob#2 ``` -------------------------------- ### Date Formatting Examples Source: https://perchance.org/date-plugin A collection of examples demonstrating various date formatting options available with the date plugin. ```perchance [date().format("MMMM Do, YYYY")] = April 10th, 2026 ``` ```perchance [date().format("dddd")] = Friday ``` ```perchance [date().format("MM Do YY")] = 04 10th 26 ``` ```perchance [date().format("YYYY")] = 2026 ``` ```perchance [date().add(3, "years").format("YYYY")] = 2029 ``` ```perchance [date().format("MMMM Do YYYY, h:mm:ss a")] = April 10th 2026, 6:12:06 pm ``` ```perchance [date().format("dddd [the] Do")] = Friday the 10th ``` ```perchance [date().format("ddd, hA")] = Fri, 6PM ``` ```perchance [date().format("YYYY MM DD")] = 2026 04 10 ``` ```perchance [date().format("[Today is] dddd")] = Today is Friday ``` ```perchance [date().format("DDD")] = 100 (day of year) ``` ```perchance [date().format("DDDo")] = 100th (day of year) ``` ```perchance [date().format("DDD/YYYY")] = 100/2026 ``` ```perchance [date().format("W / YYYY")] = 15 / 2026 (week / year) ``` ```perchance [date().format("Wo [week of] YYYY")] = 15th week of 2026 ``` ```perchance [date().format("d")] = 5 (day of week) ``` ```perchance [date().format("do")] = 5th (day of week) ``` ```perchance [date().format("dd")] = Fr ``` ```perchance [date().format("ddd")] = Fri ``` ```perchance [date().format("dddd")] = Friday ``` ```perchance [date().format("M")] = 4 (month of year) ``` ```perchance [date().format("Mo")] = 4th (month of year) ``` ```perchance [date().format("MM")] = 04 (month of year) ``` ```perchance [date().format("MMM")] = Apr ``` ```perchance [date().format("MMMM")] = April ``` ```perchance [date().add(2, "months").format("MMMM")] = June ``` ```perchance [date().format("D")] = 10 (day of month) ``` ```perchance [date().format("Do")] = 10th (day of month) ``` ```perchance [date().format("DD")] = 10 (day of month) ``` -------------------------------- ### Basic Plugin Setup Source: https://perchance.org/background-image-plugin Import the plugin in the code panel and call it in the HTML panel to display a background image. ```Perchance background = {import:background-image-plugin} ``` ```HTML [background("https://i.imgur.com/64c6NnI.jpg")] ``` -------------------------------- ### Custom CSP Including Defaults Source: https://perchance.org/custom-content-security-policy To include the default allowed domains along with your custom domains, start the list with '...'. This example includes defaults and allows 'example.com'. ```url ?$csp=... example.com ``` -------------------------------- ### AI Text Generation with `startWith` Source: https://perchance.org/ai-text-plugin Use the `startWith` option to ensure the AI's generated text begins with a specific phrase. This example generates a story that starts with 'It was the night before Christmas in'. ```perchance storyPrompt instruction = Write a {spooky|silly} story involving {a} {import:object}. startWith = It was the night before Christmas in ``` -------------------------------- ### Using the Plugin Source: https://perchance.org/numerals-to-ordinal-words-plugin Examples of how to use the plugin with static numbers, variables, and other plugin functions. ```Perchance [numToOrdWord(18)] ``` ```Perchance [numToOrdWord(num)] ``` ```Perchance [numToOrdWord( dice("2d6") )] ``` ```Perchance [numToOrdWord( character.hitpoints )] ``` ```Perchance [numToOrdWord()] ``` -------------------------------- ### Get Perchance Generator Results with Node.js Source: https://perchance.org/diy-perchance-api This Node.js script demonstrates how to fetch a Perchance generator's HTML, load it into JSDOM, and access its lists and functions programmatically. Ensure you have 'jsdom' and 'node-fetch' installed. Replace 'animal-sentence' with your generator's name and 'yourListName' with the desired list name. ```javascript const { JSDOM } = require("jsdom"); // v16.4.0 const fetch = require("node-fetch"); // v2.6.1 let generatorName = "animal-sentence"; // <-- change this to your generator name let html = await fetch(`https://perchance.org/api/downloadGenerator?generatorName=${generatorName}&__cacheBust=${Math.random()}`).then(r => r.text()); const { window } = new JSDOM(html, {runScripts: "dangerously"}); // now you can use the `window` object of your generator like this: console.log(window.root.output.toString()); console.log(window.root.yourListName.toString()); window.root.character.hitpoints = 10; let charDesc = window.root.character.description.evaluateItem; window.update(); ``` -------------------------------- ### Basic Pattern Options Setup Source: https://perchance.org/pattern-maker-plugin Configure the input image and basic settings for pattern generation. Ensure the input image URL is correct. ```javascript patternOptions inputImage = https://i.imgur.com/V4trUZG.png settings width = 50 height = 50 n = 3 symmetry = 8 ``` -------------------------------- ### Persist Variable State Example Source: https://perchance.org/remember-plugin Example showing how to conditionally initialize a variable only if it has not been previously remembered. ```Perchance num = {1-10} output [if (a == undefined) {a = num.selectOne} else {a}] ``` ```HTML [remember(root, "a")] [output] ``` -------------------------------- ### Install and Use Text to Speech Source: https://perchance.org/text-to-speech-plugin Import the plugin into the code panel and use the speak function to output text. ```Perchance speak = {import:text-to-speech-plugin} ``` ```Perchance [speak("This is the perchance text to speech plugin")] ``` ```Perchance [speak(yourListName)] ``` -------------------------------- ### Verify Node.js Installation Source: https://perchance.org/perchance-discord-bot Checks if Node.js is installed and displays its version. A version greater than 14 is recommended. ```bash node --version ``` -------------------------------- ### Using the A/An plugin Source: https://perchance.org/a-an-plugin This example demonstrates how to use the A/An plugin alongside the tap-plugin to ensure correct grammar. ```Perchance an = {import:a-an-plugin} tap = {import:tap-plugin} output That's [an()] [tap(animal)]. ``` -------------------------------- ### Install PM2 Globally Source: https://perchance.org/perchance-discord-bot Installs the PM2 process manager globally, which is used to keep the bot running. ```bash npm install -g pm2 ``` -------------------------------- ### Basic Nestable Tap Plugin Usage Source: https://perchance.org/nestable-tap-plugin Demonstrates the basic setup and usage of the Nestable Tap Plugin, including defining styles and nested tap structures within the output. Ensure the plugin is imported. ```perchance tap = {import:nestable-tap-plugin} _// Styles_ main = cursor: pointer; padding: 0.2em; margin: 0.1em 0; font-weight: bold; black = [main] color: black; border: 1px solid black; red = [main] color: red; border: 1px solid red; green = [main] color: lime; border: 1px solid lime; blue = [main] color: blue; border: 1px solid blue; output The story begins with a [tap(character, black)]. character [tap(event, red)] man known as [tap(manname, blue)] [tap(adjective2, red)] [tap(animal, green)] named [tap(animalname, blue)] event manly hairy smelly adjective2 loud fluffy gentle manname Hector Balthazar Bob animal cow dog bird animalname Pip Misty Carlo ``` -------------------------------- ### Perform Non-Atomic Get and Set Source: https://perchance.org/kv-plugin This pattern is prone to race conditions because the get and set operations are not atomic. ```javascript let v = await kv.folderName.get("abc"); await kv.folderName.set("abc", v+1); ``` ```javascript let v = await kv.folderName.get("abc"); // since the above line has 'await' (i.e. it's an 'async' operation), some other code in our game/app could have fetched 'abc' data at the same time, and if it's also going to increment the value, then we'll both increment it to the same number, instead of it being incremented twice await kv.folderName.set("abc", v+1); ``` -------------------------------- ### Implement Layout Maker in Perchance Source: https://perchance.org/layout-maker-plugin Basic setup for the plugin in the code panel and rendering in the HTML panel. ```text layoutMaker = {import:layout-maker-plugin} layout debug = borders grid a a a a b a a a a b c c c c c areas a content = {hello|hi there} this is the "a" area b content = side bar thing ("b" area) c content = a sort of footer thing ("c" area) ``` ```html [layoutMaker(layout)] ``` -------------------------------- ### Example Perchance Generator URL Source: https://perchance.org/create-a-twitter-bot An example of a Perchance generator's URL, showing the format that 'your-generators-name' is derived from. ```text https://perchance.org/y6ql4555a0 ``` -------------------------------- ### Initialize Comments Plugin Source: https://perchance.org/comments-plugin Basic setup for importing and rendering the comments plugin in Perchance. ```text commentsPlugin = {import:comments-plugin} ``` ```text [commentsPlugin()] ``` -------------------------------- ### Perchance Template Conversion Example Source: https://perchance.org/ci7wlcptew Example output format for converted Abulafia templates within a Perchance list. ```text ;output 1,{{ia:{{uc:{{plural|[animal]}}}}}} 1,{{ucfirst:[animal]}}{{ia:[animal]}}{{uc:[animal]}} 1,{{ucfirst:{{ia|{{po:[animal]}}}}}} ``` -------------------------------- ### Initialize Pride Plugin Source: https://perchance.org/pride-plugin Import the plugin in the code panel and call it in the HTML panel. ```Perchance pride = {import:pride-plugin} ``` ```HTML [pride()] ```