this post was submitted on 23 May 2025
2 points (100.0% liked)

Perchance - Create a Random Text Generator

1020 readers
5 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
 

I'm trying to make my current gen in a duplicationfriendly format so ppl can just edit the Starter lists on the left to edit the styles the gen starts with. BUT ITS HARD. I did the accessing the "Starters" list thru root and it definitely has the items as seen below when it runs. but joinitems doesn't work on the object root gives and nor does it have a length or any way to iterate thru the entries to build an object out of the list entries. How do I get all the entries from the twotiered 'Starters' list in to javascript so i can access the info it contains?

all 7 comments
sorted by: hot top controversial new old
[–] VioneT@lemmy.world 1 points 2 months ago (3 children)

So what you are trying to do is that after getting the 'Starter' from the root["Starter"] you want to combine the subsequent lists into a single sentence? e.g. if the randomly selected starter from root["Starter"] is Foxpony, then you want the lists 0 to 4 to be joined into a sentence, while randomizing between the items under the 'number' lists?

You can do so with the following:

let starter = root["Starters"].selectOne // gets either Foxpony or Spaceship list object
let sentence = starter.selectAll // selects all lists under the object i.e. 0 to 4
  .map(list => list.selectOne) // iterates through the lists and selects a random item from them
  .joinItems(" ") // joins the randomized items into a single sentence
Crystalline.say(sentence)
[–] Alllo@lemmy.world 1 points 2 months ago (1 children)

nevermind. i tried and thought it would be nicer to do in perchancescript but looks like i have to do it in javascript.

i dont know why this would output 3 instead of foxpony

off to do it all in javascript i guess. ty for teh help tho

[–] VioneT@lemmy.world 2 points 2 months ago (2 children)

Okay, so in your a you have all items from the root["Starter"]. If you use a[0] it would indeed select Foxpony BUT it would also evaluate and select an item on that list, so it would output one of its children (0 to 4) which is why you got 3 as the result. You can get the name of the list with a[0].getName to get Foxpony then use .selectOne to get an item from it which would result to selecting, for example, 1 and it would output an item from under that.

[–] Alllo@lemmy.world 2 points 2 months ago

and with that i was able to do it :)

thank you so much!

[–] Alllo@lemmy.world 1 points 2 months ago

o cool ty :)

[–] Alllo@lemmy.world 1 points 2 months ago

thank you for the help vioneT! im not trying to do anything random and combining was just a workaround i was thinking could work. the gen is here with the html code at the bottom

im trying to read thru the list of lists and create an element for each thing. Every number translated in to an element and every individual description translated in to an element. So i need to, not randomly, get the whole list. Trying For loops now to iterate thru each level to access every item and then I can just make the elements on each level of For loop, but it just repeats like 9+ blank popups instead when i test whether it's outputting correctly.