this post was submitted on 21 Apr 2025
2 points (100.0% liked)

Perchance - Create a Random Text Generator

915 readers
8 users here now

⚄︎ Perchance

This is a Lemmy Community for perchance.org, a platform for sharing and creating random text generators.

Feel free to ask for help, share your generators, and start friendly discussions at your leisure :)

This community is mainly for discussions between those who are building generators. For discussions about using generators, especially the popular AI ones, the community-led Casual Perchance forum is likely a more appropriate venue.

See this post for the Complete Guide to Posting Here on the Community!

Rules

1. Please follow the Lemmy.World instance rules.

2. Be kind and friendly.

  • Please be kind to others on this community (and also in general), and remember that for many people Perchance is their first experience with coding. We have members for whom English is not their first language, so please be take that into account too :)

3. Be thankful to those who try to help you.

  • If you ask a question and someone has made a effort to help you out, please remember to be thankful! Even if they don't manage to help you solve your problem - remember that they're spending time out of their day to try to help a stranger :)

4. Only post about stuff related to perchance.

  • Please only post about perchance related stuff like generators on it, bugs, and the site.

5. Refrain from requesting Prompts for the AI Tools.

  • We would like to ask to refrain from posting here needing help specifically with prompting/achieving certain results with the AI plugins (text-to-image-plugin and ai-text-plugin) e.g. "What is the good prompt for X?", "How to achieve X with Y generator?"
  • See Perchance AI FAQ for FAQ about the AI tools.
  • You can ask for help with prompting at the 'sister' community Casual Perchance, which is for more casual discussions.
  • We will still be helping/answering questions about the plugins as long as it is related to building generators with them.

6. Search through the Community Before Posting.

  • Please Search through the Community Posts here (and on Reddit) before posting to see if what you will post has similar post/already been posted.

founded 2 years ago
MODERATORS
 

Hello Everyone!

I'm a bit of a novice when it comes to html/perchance scripting and I've been bashing my head against trying to get something to work in perchance that I could solve pretty easily outside of perchance.

Fundamentally, all I want is to be able to input a number and it roll on a table that number of times and add the results together to an output. This is for individual treasure that I am doing in my D&D game, and I'm just tired of pressing the buttons and adding the values together. I've scrounged around other loot gens in perchance, none of them seem to do this that I could lift anything from, and any form of LLM doesn't understand perchance scripting at all...

Currently, my old set up for this is pretty basic.

PERCHANCE

dice = {import:dice-plugin} excludeItems = {import:exclude-items-plugin} joinLists = {import:join-lists-plugin} filterList = {import:filter-list-plugin} consumableListLoop = {import:consumable-list-loop-plugin} image = {import:text-to-image-plugin} tap = {import:tap-plugin} rollTable = {import:roll-table-plugin} clicked = terrain

output3 [rollTable(itreasureone, dice("1d100"))] ^[clickedtreasure == "CR0+"] [rollTable(itreasuretwo, dice("1d100"))] ^[clickedtreasure == "CR5+"] [rollTable(itreasurethree, dice("1d100"))] ^[clickedtreasure == "CR11+"] [rollTable(itreasurefour, dice("1d100"))] ^[clickedtreasure == "CR17+"]

itreasureone 1-30, [dice("5d6")] Copper Pieces 31-60, [dice("4d6")] Silver Pieces 61-70, [dice("3d6")] Electrum Pieces 71-95, [dice("3d6")] Gold Pieces 96-100, [dice("1d6")] Platinum Pieces

itreasuretwo 1-30, [dice("4d6") * 100] Copper Pieces and [dice("1d6") * 10] Electrum Pieces 31-60, [dice("6d6") * 10] Silver Pieces and [dice("2d6") * 10] Gold Pieces 61-70, [dice("3d6") * 10] Electrum Pieces and [dice("2d6") * 10] Gold Pieces 71-95, [dice("4d6") * 10] Gold Pieces 96-100, [dice("2d6") * 10] Gold Pieces and [dice("3d6")] Platinum Pieces

itreasurethree 1-20, [dice("4d6") * 100] Silver Pieces and [dice("1d6") * 100] Gold Pieces 21-35, [dice("1d6") * 100] Electrum Pieces and [dice("1d6") * 100] Gold Pieces 36-75, [dice("2d6") * 100] Gold Pieces and [dice("1d6") * 10] Platinum Pieces 76-100, [dice("2d6") * 100] Gold Pieces and [dice("2d6") * 10] Platinum Pieces

itreasurefour 1-15, [dice("2d6") * 1000] Electrum Pieces and [dice("8d6") * 100] Gold Pieces 16-55, [dice("1d6") * 1000] Gold Pieces and [dice("1d6") * 100] Platinum Pieces 56-100, [dice("1d6") * 1000] Gold Pieces and [dice("2d6") * 100] Platinum Pieces


HTML


My initial thoughts was to add in something in html like this

and just use the "num" value as a decreasing value in a while loop, though I can't find anything on the syntax for the while loop use case in perchance even though it seems to be working well enough to crash?

Ultimately, been trying to get it to output (in case of like 6 rolls being made) something basic like

55cp, 0sp, 15ep, 10gp, 4pp

Any pointers would be appreciated!

you are viewing a single comment's thread
view the rest of the comments
[–] VioneT@lemmy.world 2 points 2 months ago

You can use the .selectMany(number).joinItems(delimiter) method:

<p id="out3">[output3.selectMany(num.value).joinItems(', ')]</p>

<input id="num" type="number" min="1" value="1">