Repository navigation
Generation Filters
Red Reaper edited this page Oct 11, 2026
·
9 revisions
Filters are pure JS snippets evaluated in the generation loop (study the system-gen.js file). The generator retries (up to 1000 attempts by default) until the predicate succeeds or the limit is reached. Although eval() creates an XSS-vulnerability, it also gives much power to an experienced user, allowing to search systems with very specific bodies, and potentially to even alter the generation process.
A filter consists of one mandatory script, two optional scripts, and a JSON entry (see _filters.json).
Three script slots are:
- Pre-generation (optional) - runs once before the system generation loop.
-
Predicate / search script (mandatory) - runs on every body after each system generation (attempt); calling
finish()function stops the loop. - Post-generation (optional) - runs after the generation loop.
See the filters folder for examples.
To add a new filter into the app, you need to:
- Create a text file somewhere in the
filtersfolder. - Rename it and change its extention to
.js. [my_filter.js] - If your filter needs pre-gen and/or post-gen script(s), create files in the similar to stated above manner, only this time adding
.preor.postto the file's name. [my_filter.js&my_filter.pre.js] - Write JS code snippets into the file(s) as if they'd be a part of the code in
system-gen.js. - In
_filters.json, add a new entry to the scripts array of the desired group. An entry has these properties:-
thumb(string): Thumbnail, is expected to have emojis and snippets of HTML (see script-selector.js). -
name(string): Filter's name/header in the filters list. -
desc(string): A brief description for the filter. -
rarity(number): An estimate of how many systems it takes to generate on average to find the specified object. Calculated and set manually, as an average value from at least 10 successful searches. -
script(string): A path to the search script starting from thefiltersfolder, and the script's file name, without the suffix and the extention. [filters/my_dir/my_filter.js->my_dir/my_filter] -
pre(bool): Indicating if a pre-generation script is used (true/false). -
post(bool): Indicating if a post-generation script is used (true/false).
-
- Check if the filter appears in the filters list, is loads correctly, and is works correctly.
- Test the filter and, preferably, calculate rarity. Be ware that one system generation will take about 0.2s of time, thus, ~20s per 1000 attempts or ~3.3 minutes per 10000 attempts.
To add a new group inside the filters list, add the following object to the JSON:
-
thumb(string): Group's thumbnail, similar to a script. -
groupName(string): Group's name/header. -
scripts(array ([])): Array of filter entries.