Flair
English
code
youmakeai commited on
Commit
8375abb
·
verified ·
1 Parent(s): 0c78ab4

Delete How perchance works for beginners.txt

Browse files
Files changed (1) hide show
  1. How perchance works for beginners.txt +0 -342
How perchance works for beginners.txt DELETED
@@ -1,342 +0,0 @@
1
- - // Note: Text that comes after "//" is ignored, which allows
2
- // you to write notes - like the one you're reading now!
3
- // - Below is an example of an EDITOR PANEL
4
- // - title comes after plugins, plug-in start line number one.
5
-
6
- title
7
- Your Generator's Title
8
-
9
- output
10
- {This|That} [animal] is so [adjective]!
11
- I wish I could [verb] that [animal].
12
- Aren't [animal.pluralForm] just so [adjective]?
13
- There must be at least {1-10} [animal]{s} [location]!
14
- THE [animal.upperCase]! It's eating the {import:common-noun}!
15
- {A} [animal] is a bit like {a} {import:common-noun}. // {A} and {a} will automatically choose "a" and "an" as appropriate
16
-
17
- animal
18
- pig
19
- cow
20
- chicken
21
- zebra
22
- crayfish
23
- jellyfish^0.5 // this item is HALF as likely as the others
24
- worm^2 // this item is TWICE as likely as the others
25
-
26
- adjective
27
- small
28
- big
29
- cute
30
- sneaky
31
- unusual
32
- helpful
33
- mean
34
-
35
- verb
36
- pat
37
- befriend
38
- help
39
-
40
- location
41
- on {the|this|that} island
42
- in {the|this|that} valley
43
- {around|in} here
44
- over there
45
- under this {thing^2|thingie}
46
-
47
-
48
- // Tips:
49
- // - Highlight multiple lines and press Tab or Shift+Tab to indent and un-indent them all an once
50
- // - You can change the URL of your generator by clicking the "settings" button in the top-right
51
- // - You can use the sparkle button in the lower-right of the screen to ask the AI to adjust the visual design of your generator.
52
- // - Add background images, fonts, and other stuff with plugins: perchance.org/plugins
53
- // - Here are some generators you might like to import: perchance.org/useful-generators
54
- // - Read this page after reading the tutorial: perchance.org/examples
55
- // - There's a gear button in the top-left which you can use to make the lines wrap around when they reach the edge of the screen, and to change the font size. Also, if you add $output=[this.joinItems("<br>")] as the first or last item in your list, then writing [yourListName] will magically output all of the items joined together with <br> (which means "line break" in HTML - i.e. a line separator), rather than outputting a random item from the "yourListName" list.
56
- // - Ask our friendly community members if you need help: lemmy.world/c/perchance
57
-
58
- // - Below is an example of an HTML PANEL
59
-
60
- <!-- Learn 'HTML' here: https://www.khanacademy.org/computing/computer-programming/html-css -->
61
-
62
- <h1>[title]</h1>
63
- <p style="margin:1em auto; padding:0 1em; max-width:700px;">[output]</p>
64
- <button onclick="update()">randomize</button>
65
- <br>
66
-
67
- <!-- The line below makes it so if your device is in dark mode, then the default text color is switched to white, and the default background color is switch to black. -->
68
- <style> html { color-scheme: light dark; } </style>
69
- // - this was an actual sample of how perchance works.
70
-
71
- // editor panel below
72
-
73
- $meta
74
- title = Create a Random Generator
75
-
76
- pride = {import:pride-plugin}
77
-
78
- // Yep, even the Perchance homepage is technically a "generator", but all the content is in the HTML code in the lower-right editor.
79
-
80
- // html below
81
-
82
- <h1 style="position:fixed; top:-1000px;">Create a Random Generator</h1>
83
- <h2 id="header" style="font-size:200%; margin-top:1em;">[pride()] Welcome to Perchance! [pride()]</h2>
84
- <main>
85
-
86
- <p>Perchance is a platform for creating and sharing random generators. To create a random generator you simply create lists which reference other lists:</p>
87
-
88
- <div style="position:relative;">
89
- <pre>output
90
- Your \[pack\] contains \[item\], \[item\] and \[item\].
91
-
92
- item
93
- a few coins
94
- an old \{silver|bronze\} ring
95
- a handkerchief
96
- a shard of bone
97
- some lint
98
- a tin of tea leaves
99
-
100
- pack
101
- purse
102
- backpack
103
- bag
104
- pack
105
- knapsack
106
- rucksack
107
- </pre>
108
- <a href="/rg4m14ri#edit"><div style="position:absolute;bottom:1em;right:1em;background: #14b914; background:light-dark(#14b914, #038003); color:white;padding: 0.5em;width:max-content;border-radius: 2px; box-shadow: 0px 2px 2px #0000005c;">try this example</div></a>
109
- </div>
110
- <p>So, for example, whenever you write <code>\[pack\]</code>, a random item from the "pack" list will be put in its place — as shown in <a href="https://user-uploads.perchance.org/file/bc63c883358b59575af1b8a142b90834.mp4" target="_blank">this animation</a> by <a href="https://perchance.org/vionet20-gens" target="_blank">Vionet20</a>.</p>
111
- <p><a href="/rg4m14ri#edit">Here's a link</a> to a minimal perchance generator based on the above code. You can edit it, save your own version, and share it.</p>
112
- <p>You can change the odds of items like so:</p>
113
- <pre>
114
- pack
115
- purse
116
- backpack ^2
117
- bag
118
- ...
119
- </pre>
120
- <p>That makes "backpack" twice as likely as the others to be chosen when we write <code>\[pack\]</code>. You can import other peoples' generators like this:</p>
121
- <pre>
122
- sentence
123
- I need a new \{import:noun\}.
124
- Quickly, \{import:verb\}!
125
- </pre>
126
- <p>You can also alter the capitalisation, pluralisation, tense, and other properties of your word lists. Here's how to play around with capitalisation, for example:</p>
127
- <pre>
128
- sentence
129
- \[name.titleCase\], can you hear me?
130
- HELLO, \[name.upperCase\]!
131
-
132
- name
133
- patricia
134
- khalid
135
- anaya
136
- ...
137
- </pre>
138
- <p>There are a bunch of different shorthand notations to make common tasks easier:</p>
139
- <pre>
140
- sentence
141
- \{She|He\} was about \{15-20\}0cm tall and was carrying \{1-3\} \{import:concrete-noun\}\{s\}.
142
- </pre>
143
- <p>If you prefer to learn via video, here's a great unofficial introduction video by YouTuber <a href="https://www.youtube.com/@Chaoclypse" target="_blank">Chaoclypse</a> who is using Perchance to create RPG generators:</p>
144
- <p style="text-align:center; margin-bottom:0.1rem;"><iframe width="560" height="315" style="max-width:100%;" src="https://www.youtube-nocookie.com/embed/2DRSuHDPU6I?si=_Ih0m9pR5qt-2b0h&autoplay=0&rel=0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe></p>
145
- <p style="text-align:center; margin-top:0.1rem; font-size:70%;">(btw, feel free to share your own Perchance video tutorials on <a href="https://lemmy.world/c/perchance" target="_blank">the community forum</a> - you might get featured here!)</p>
146
- <p>The above examples only show the <b>absolute basics</b> of Perchance! If you'd like to learn more, check out the <a href="/tutorial">tutorial</a>, and start playing around with a <a href="/minimal#edit">minimal example</a> (or the <a href="/basic-template#edit">basic template</a>). Check out the <a href="/examples">examples</a> page and this <a href="/aqr03wn1#edit">somewhat complexified version</a> of the previous backpack example for some demonstration of advanced features.</p>
147
-
148
- <div id="next-step-buttons-ctn" style="display:flex; justify-content:center;">
149
- <a href="/generators" style="display:inline-block; text-decoration:none; color:white; background: #ea8616; background:light-dark(#ea8616, #cd730f); border:0; outline:none; padding:0.5em 1em; border-radius:3px; font-size:120%; margin:1em; box-shadow: 0px 2px 2px #00000029;">View Creations 🔧</a>
150
- <a href="/minimal#edit" style="display:inline-block; text-decoration:none; color:white; background: #00a3ce; background:light-dark(#ea8616, #0084a7); border:0; outline:none; padding:0.5em 1em; border-radius:3px; font-size:120%; margin:1em; box-shadow: 0px 2px 2px #00000029;">Start Creating ⚄</a>
151
- <a href="/tutorial" style="display:inline-block; text-decoration:none; color:white; background: #4abe4a; background:light-dark(#4abe4a, #0f8e0f); border:0; outline:none; padding:0.5em 1em; border-radius:3px; font-size:120%; margin:1em; box-shadow: 0px 2px 2px #00000029;">Keep Learning 📚</a>
152
- </div>
153
- <style>
154
- @media screen and (max-width: 800px) {
155
- #next-step-buttons-ctn {
156
- flex-direction:column;
157
- }
158
- }
159
- </style>
160
-
161
- <p>Once you've created a generator, you can <b>share it</b> with others by simply sharing the URL. You can change the URL in the "settings" menu. You can also <b>download it</b> as a single HTML file so that you can run it offline, or even turn it into a <a href="https://perchance.org/create-a-twitter-bot" target="_blank" style="font-weight:bold;">Twitter bot</a> or a <a href="https://perchance.org/create-a-tumblr-bot" target="_blank" style="font-weight:bold;">Tumblr bot</a>. It's also easy to <b>embed it</b> in your own website:</p>
162
- <pre>
163
- &lt;iframe src="https://null.perchance.org/my-generator-name" style="width:100%; height:600px; border:none;"&gt;&lt;/iframe&gt;
164
- </pre>
165
- <p>And a note to coders: It's also possible to <a href="/diy-perchance-api">set up an API server</a> for your generator, even though Perchance doesn't have an "official" API at this point. It's also possible to <a href="/perchance-discord-bot" target="_blank" style="font-weight:bold;">set up a Discord bot</a> which will respond to messages with the output of a generator that you choose.</p>
166
-
167
- <p>We have a <a href="https://lemmy.world/c/perchance">Lemmy community</a> which you might like to join. Feel free to share your creations there or ask questions if you need some help building your generator. Also check out the work-in-progress <a href="/useful-generators">useful generators</a> list which might have some generators that you'd find useful for importing into your own generator.</p>
168
- <p>If you're looking for a simple random generator maker that just randomly selects one of several different items that you specify, then you can still use Perchance, but it might be a bit excessive for such a simple task. That said, the advantage of using Perchance for something like this is that it makes it really easy to add different weights/chances to each item and to extend it with some additional complexity later if needed. Perchance is designed to allow you to create random generators that have a lot of complexity, without requiring any existing coding knowledge, and with a fairly simple interface.</p>
169
- <p>Perchance is based on <a href="https://www.khanacademy.org/computing/computer-programming/html-css" target="_blank">HTML/CSS</a>, and <a href="https://www.khanacademy.org/computing/computer-programming/programming" target="_blank">JavaScript</a>, and my secret mission with Perchance is to get people interested in coding with a smooth, fun learning-curve. If you enjoy using Perchance and want to take your coding skills to the next level, you might like to learn to code on <a href="https://www.khanacademy.org/computing/computer-programming" target="_blank">Khan Academy</a>, or <a href="https://scratch.mit.edu/" target="_blank">Scratch</a>.</p>
170
- <p>Finally, Perchance's structure is based on other awesome random text languages like <a href="http://orteil.dashnet.org/randomgen">randomgen</a> by Orteil and <a href="https://github.com/rant-lang/rant">Rant</a> by TheBerkin. Many thanks to these and other <a href="https://en.wikipedia.org/wiki/Domain-specific_language">DSL</a> creators which inspired Perchance's syntax and functionality. You might also like to check out <a href="https://chartopia.d12dev.com/">Chartopia</a> - another website which allows you to make random generators. If you like the HTML/JS coding aspect of Perchance, and don't really need the generator stuff, then <a href="https://neocities.org/">neocities.org</a> may also be interesting to you.</p>
171
- <p>Thanks to the contributors behind these open source software projects:</p>
172
- <ul style="text-align:left;">
173
- <li><a href="https://github.com/nlp-compromise/compromise">Compromise</a>: A JavaScript natural language library that powers <code>pastTense</code> and <code>pluralForm</code> and the like.</li>
174
- <li><a href="https://nathancahill.github.io/Split.js/">Split.js</a>: A library that allows you to easily split the screen up into resizable quadrants.</li>
175
- <li><a href="https://mongodb.com">MongoDB</a>: A great document/NoSQL database. I use it for everything.</li>
176
- <li><a href="https://expressjs.com">Express.js</a>: Helps serve you this webpage and power the internal APIs of Perchance.</li>
177
- </ul>
178
- <p>Thanks for checking out Perchance! •ᴗ•</p>
179
- </main>
180
- <p style="text-align:center; font-size:200%; opacity:0.2; margin-top:0.5em;"><span>⚄&#xFE0E;</span></p>
181
- <p style="margin-bottom:2rem; font-size:80%; color:grey; text-align:center;"><a style="color:inherit; text-decoration:none;" href="/privacy-policy" target="_blank">Privacy Policy</a></p>
182
- <br/>
183
-
184
- <style>
185
- ul li {
186
- margin-top:0.5em;
187
- }
188
- main {
189
- max-width:900px;
190
- margin:0 auto;
191
- background: #fff;
192
- background: light-dark(#fff, #101010);
193
- padding:1em;
194
- border-radius:3px;
195
- box-shadow: 0 0.5px 0 0 #ffffff inset, 0 1px 2px 0 #B3B3B3;
196
- box-shadow: 0 0.5px 0 0 light-dark(#fff, #060606) inset, 0 1px 2px 0 light-dark(#B3B3B3, #2c2c2c);
197
- }
198
- main p:first-child {
199
- margin-top:0;
200
- }
201
- p { text-align:left; line-height: 1.4em; }
202
- body {
203
- background-color:#f6f6f6;
204
- background-color: light-dark(#f6f6f6, #000);
205
- color: black;
206
- color: light-dark(black, #d6d6d6);
207
- }
208
- pre {
209
- text-align:left;
210
- background: #333;
211
- background: light-dark(#333, #212121);
212
- color: #e2e2e2;
213
- padding: 1em;
214
- border-radius: 2px;
215
- tab-size: 2;
216
- -moz-tab-size: 2;
217
- -o-tab-size: 2;
218
- -webkit-tab-size: 2;
219
- }
220
- code {
221
- background: #eff0f1;
222
- background: light-dark(#eff0f1, #272727);
223
- padding: 1px 5px;
224
- white-space: nowrap;
225
- }
226
- h2 {
227
- margin-top: 1.5em;
228
- }
229
- @media screen and (max-width: 600px) {
230
- #header {
231
- font-size:1.6rem !important;
232
- }
233
- }
234
- html { color-scheme: dark light }
235
- </style>
236
-
237
- pride = {import:pride-plugin}
238
- hubData = {import:hub-external-card}
239
-
240
- // Here's the code for the comments section.
241
- // If you want a similar comment section on your generator,
242
- // then copy this code, and the "comments section" code in the
243
- // HTML editor (bottom-right panel).
244
- commentsPlugin = {import:comments-plugin}
245
- commentOptions
246
- width = 100%
247
- height = 100%
248
- commentPlaceholderText = Add a friendly comment.
249
- submitButtonText = Submit
250
- adminPasswordHash = 98a407adbe9b5f82e04743052c96700b32b41fbd0b086c1508e632538ed5c948
251
- bannedUsers
252
- 63597638cc2c54e646c0
253
- bd2b6e549d9265095875
254
- 8d773b11eb09b74fcef6
255
- 453d45538bab1c684dfc
256
- 8f0373f1b3987207c2c6
257
- 2b48d8482b43363e186a
258
- 0c6b24e958846cb48540
259
- 428f8fe038bd2208455a
260
- G3UB-88b3244b8bd110819eb7
261
-
262
-
263
-
264
- // Every page on perchance is a "generator", even this one!
265
- // But since there's no need for random stuff on this page
266
- // (it's just a list of recently updated generators), most
267
- // of the code for this page is in the HTML panel (the
268
- // bottom-right text editor).
269
-
270
- <h1><a target="_blank" href="/pride-plugin">[pride()]</a>[new Date().getDate() === 19 ? "🕯️" : ""] Recently Updated Generators [new Date().getDate() === 19 ? "🕯️" : ""]<a target="_blank" href="/pride-plugin">[pride()]</a></h1>
271
- <p style="opacity:0.4; margin:0;" class="subtitle">(You can remove your generator from this list by clicking "make private" in your generator's settings)</p>
272
-
273
- <!-- comments section-->
274
- <div style="position:fixed; bottom:0; right:0; height:max-content; width:min(100%, 400px); z-index:100; max-height:100vh;">
275
- <div style="background:#1a1a1a;color:white;border: 1px solid #303030;border-top-left-radius:3px;border-top-right-radius:3px;cursor:pointer;padding:0.25rem;border-bottom: none;" data-visible="false" onclick="commentsCtnEl.style.display = JSON.parse(this.dataset.visible) ? 'none' : ''; this.dataset.visible = !JSON.parse(this.dataset.visible);">💬 Comments</div>
276
- <div id="commentsCtnEl" style="display:none; height:min(600px, 80vh); ">[commentsPlugin(commentOptions)]</div>
277
- </div>
278
-
279
- <div class="suggested-links">
280
- <a href="/plugins" style="font-weight:bold;">plugins</a>
281
- <a href="/templates" style="font-weight:bold;">templates</a>
282
- <a href="/resources" style="font-weight:bold;">resources</a>
283
- <a href="/text-to-image-plugin">text-to-image-plugin</a>
284
- <a href="/ai-text-plugin" class="highlighted-suggested-link">ai-text-plugin</a>
285
- <a href="/comments-plugin">comments-plugin</a>
286
- <a href="/pattern-maker-plugin">pattern-maker-plugin</a>
287
- <a href="/image-layer-combiner-plugin">image-layer-combiner-plugin</a>
288
- <a href="/layout-maker-plugin">layout-maker-plugin</a>
289
- <a href="/create-instance-plugin">create-instance-plugin</a>
290
- <a href="/popular-generators">popular-generators</a>
291
- <a href="/create-a-twitter-bot">create-a-twitter-bot</a>
292
- <a href="/diy-perchance-api">diy-perchance-api</a>
293
- <a href="/perchance-discord-bot">perchance-discord-bot</a>
294
- <a href="/tap-plugin">tap-plugin</a>
295
- <a href="/wheel-plugin">wheel-plugin</a>
296
- <a href="/tooltip-plugin">tooltip-plugin</a>
297
- <a href="/background-image-plugin">background-image-plugin</a>
298
- <a href="/font-plugin">font-plugin</a>
299
- <a href="/generator-stats-plugin">generator-stats-plugin</a>
300
- </div>
301
- <style>
302
- .suggested-links {
303
- display:flex;
304
- padding:1rem;
305
- justify-content:center;
306
- flex-wrap:wrap;
307
- }
308
- .suggested-links a {
309
- margin:0.25rem;
310
- background:#f2f2f2;
311
- padding:0.25rem;
312
- box-shadow: 0px 1px 2px 0px #e3e3e3;
313
- border: 1px solid #bbb;
314
- }
315
- </style>
316
-
317
-
318
- <!--
319
- To make this work, you want to map your items twice in .marquee, and halve the total width of .marquee to create the "infinite" wraparound
320
- -->
321
-
322
- <!--<div class="marquee-container" style="margin-bottom:2rem; display:none">
323
- <div class="marquee">
324
- <div class="item">
325
- <div class="card">🤪</div>
326
- </div>
327
- <div class="item">
328
- <div class="card">🤪🤪</div>
329
- </div>
330
- <div class="item">
331
- <div class="card">🤪🤪🤪</div>
332
- </div>
333
- <div class="item">
334
- <div class="card">🤪🤪🤪🤪</div>
335
- </div>
336
- <div class="item">
337
- <div class="card">🤪🤪🤪🤪🤪</div>
338
- </div>
339
- </div>
340
- </div>
341
-
342
- // these are just some examples on how perchance.org works.