- TypeScript 88.2%
- CSS 11.8%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Register the `randpick` macro via `setupPickMacro()` in the pick service, reusing the existing `pickFromOptions()` logic. Supports uniform and weighted random selection with the same syntax as the %%pick%% placeholder. Also fix README: correct casing for randomWord/shuffle macros and mark shuffle as macro-capable instead of placeholder-only. |
||
| .husky | ||
| .vscode | ||
| dist | ||
| src | ||
| types | ||
| .gitignore | ||
| .lintstagedrc.json | ||
| biome.json | ||
| bun.lock | ||
| commitlint.config.ts | ||
| manifest.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
st-randomness-helpers
st-randomness-helpers is a extension for SillyTavern.
Features
WordLists
WordList are plaintext files containing one or more words per line. The name of the file is the name of the WordList.
Macros
Register macros that are usually replaced with a value at save time.
Placeholders
Placeholders are strings that are replaced with a value at generation time.
Slash Commands
Register slash commands that are used for scripting.
/replaceRandom (alias: /randomReplace)
Replace placeholders in the provided text with random values. This command processes all supported placeholder types in a single operation. Example: /replaceRandom I have a %%randomWord::PetSpecies%% myself
Services
RandomWord
Get a random word from a WordList. Can be used as a Macro or a Placeholder. Macro format: {{randomWord::WordListName}}. Placeholder format: %%randomWord::WordListName%%.
Shuffle
Shuffle a list of values. Can be used as a Macro or a Placeholder. Macro format: {{shuffle::Value1::Value2::Value3;;separator}}. Placeholder format: %%shuffle::Value1::Value2::Value3;;separator%%. Example: %%shuffle::Value1::Value2::Value3;;, %% will return Value3, Value1, Value2.
Pick
Pick a random value from a list of values. Can be used as a Macro or a Placeholder.
- Macro format:
{{randpick::Value1::Value2::Value3}} - Placeholder format:
%%pick::Value1::Value2::Value3%%
Example: %%pick::Red::Blue::Green%% will return one of Red, Blue, or Green randomly.
Uniform Pick (default)
When no weights are specified, all options have an equal chance of being chosen.
Macro: {{randpick::Option1::Option2::Option3}}
Placeholder: %%pick::Option1::Option2::Option3%%
Example: %%pick::Red::Blue::Green%% → each color has a 33.3% chance.
Weighted Pick
You can assign proportional weights to options using the weight;;value syntax. The probability of each option is weight / totalWeight.
Macro: {{randpick::<weight>;;<value>::<weight>;;<value>::...}}
Placeholder: %%pick::<weight>;;<value>::<weight>;;<value>::...%%
Example: %%pick::5;;Red::3;;Blue::2;;Green%% → Red has 50% chance, Blue 30%, Green 20% (total weight = 10).
Rules:
- Options without a valid weight (or without
;;) default to weight1. - Options with weight
0or negative are excluded from the selection. - If no valid weighted options remain after filtering, the result is an empty string.
- Mixing weighted and unweighted options is supported—unweighted options get weight
1. For example:%%pick::5;;Common::Rare::5;;Legendary%%—CommonandLegendaryeach have 5/11 ≈ 45.5% chance,Rarehas 1/11 ≈ 9.1% chance.