Skip to content
Red Reaper edited this page Oct 11, 2026 · 9 revisions

What is a filter?

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.

Adding a new filter

To add a new filter into the app, you need to:

  1. Create a text file somewhere in the filters folder.
  2. Rename it and change its extention to .js. [my_filter.js]
  3. 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 .pre or .post to the file's name. [my_filter.js & my_filter.pre.js]
  4. Write JS code snippets into the file(s) as if they'd be a part of the code in system-gen.js.
  5. 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 the filters folder, 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).
  6. Check if the filter appears in the filters list, is loads correctly, and is works correctly.
  7. 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.

Clone this wiki locally