Perchance - Create a Random Text Generator
⚄︎ 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.
- The full rules are posted here: (https://legal.lemmy.world/)
- User Rules: (https://legal.lemmy.world/fair-use/)
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
andai-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.
view the rest of the comments
Also, would be useful for things like having $output be a function. But give it properties also. Unsure how to do that currently. ...Though, also not sure if this $onload() thing would let that work anyway.
Any advice on doing this? @[email protected]
It's hacky, but I do that like this:
I have thought about something like
$onLoad
before, but there were some complications. Currently the lists panel is purely "declarative" (loosely speaking, in the sense that no state is altered during parsing/init) and all actual execution is done via calls from the HTML panel. It's definitely possible to have something like$onLoad
but it does lead to a few extra "if/thens" that devs need to keep in their mind when importing something, and I'd need to change some ~deep-ish engine code. When I've had this need in the past I also noticed that I sometimes wanted it to only run if it was a direct import - i.e. not an import of an import. So there are a few DX questions there too. For now I think this one is further down the todo/to-think-about list, since it's pretty easy to just add[yourPlugin({init:true})]
to the top of the HTML panel.I see. So is that only run once, to store it in the local list-variable by the user? That's an interesting way to do it. And lets us add properties... but that would only work after it's accessed? Or could the user do [plugin.prop] and it would work as the first code block?
Ah, no, good catch - that would have re-run every time. I've updated the code above to fix that.
Yep,
$output
will resolve towindow.__fooPluginFn
which is thefoo
function, so if you've gotfooPlugin={import:foo-plugin}
then you can writefooPlugin.prop
immediately and it'll work fine.Cool 👍
Basically, an
$onload
function to be called like that automatically would be all it takes, I think. I don't think I've seen the actual importing code, but presumably it injects stuff into the top-level page or something. At which point it could call the onload maybe?