Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

SillyTavern-LALib

> 编程语言
Open source

Library of helpful STScript commands for SillyTavern.

100 stars0 likes2 views
WebsiteGitHub

About

Library of helpful STScript commands for SillyTavern.

LALib

Library of STScript commands.

  • Help (lalib?)
  • Boolean Operations (=, test, and, or, not)
  • List Operations and Loops (pop, push, shift, unshift, foreach, map, whilee, reduce, groupby, sorte, flatten, filter, find, slice, splice, shuffle, pick, reverse, dict, keys)
  • Split & Join (split, join)
  • Text Operations (trim, pad-start, pad-end, pad-both, diff, json-pretty, substitute, encodeURIComponent, decodeURIComponent, wordcount, sentencecount, segment)
  • Regular Expressions (re-escape, re-test, re-replace, re-exec)
  • Accessing & Manipulating Structured Data (getat, setat)
  • Exception Handling (try, catch)
  • Null Handling (ifempty, ifnullish)
  • Copy & Download (copy, download)
  • DOM Interaction (dom)
  • Characters (char-get)
  • Group Chats (memberpos, group-get)
  • Conditionals - switch (switch, case)
  • Conditionals - if (ife, elseif, else, then)
  • World Info (wi-list-books, wi-list-entries, wi-activate, wi-trigger)
  • Costumes / Sprites (costumes)
  • Quick Replies (qr-edit, qr-add)
  • Chat Messages (swipes-get, swipes-get, swipes-list, swipes-count, swipes-index, swipes-add, swipes-del, swipes-go, swipes-swipe, message-edit, message-move, message-get, message-list)
  • Chat Management (chat-list, chat-parent, message-on, message-off, message-listeners, role-swap)
  • Time & Date (timestamp)
  • Async (fireandforget)
  • Logging (console-log, console-warn, console-error)
  • Audio (sfx)
  • Miscellaneous (fonts)
  • Web Requests (fetch, $, $$)

Requirements

  • (optional) Costumes Plugin for /costumes command.

Commands

Help

/lalib?

  • (slash|expressions)? = slash
    (optional) help topic

Lists LALib commands

Examples
stscript
/lalib? |
// command documentation |
stscript
/lalib? expressions |
// expressions documentation |

Boolean Operations

/=

  • ...[expression variables:bool|closure|dictionary|list|number|string]?
    (optional) named arguments assigned to scoped variables to be used in the expression
  • ...(string)
    boolean / arithmetic expression

Evaluates a boolean or arithmetic expression

See /lalib? expressions for more details on expressions.

Examples
stscript
/= true or false |
stscript
/= 1  3 + 3 = 6) |
stscript

/reduce initial=10 [1,2,3] {: acc= cur= /= acc + cur :} |
// returns 16 (10+1 = 11 -> 11+2 = 13 -> 13 + 3 = 16) |
stscript

/let x [["a",1],["b",2],["c",3]] |
/reduce initial={} {{var::x}} {: acc= cur=
    /var key=acc index={: /= cur.0 :}() {: /= cur.1 :}() |
    /return {{var::acc}} |
:} |
// returns {"a":"1","b":"2","c":"3"} |

/groupby

  • (list)
    the list to group
  • ...(string|closure)
    the expression or closure to evaluate

Groups the elements of a given list according to the string values returned by a provided expression or closure.

Examples
stscript

/return [
    {"x":"a", "y":1},
    {"x":"b", "y":2},
    {"x":"c", "y":3},
    {"x":"a", "y":4},
    {"x":"a", "y":5},
    {"x":"b", "y":6}
] |
/groupby {{pipe}} item.x |
// returns {"a": [{...}, {...}, {...}], "b": [{...}, {...}], "c": [{...}]}
                 |
stscript

/return [
    {"x":"a", "y":1},
    {"x":"b", "y":2},
    {"x":"c", "y":3},
    {"x":"a", "y":4},
    {"x":"a", "y":5},
    {"x":"b", "y":6}
] |
/groupby {{pipe}} {: /getat index=x {{var::item}} :} |
// returns {"a": [{...}, {...}, {...}], "b": [{...}, {...}], "c": [{...}]}
                 |
stscript

/return [
    "foo",
    "foo",
    "bar"
] |
/groupby {{pipe}} item |
// returns {"foo":["foo","foo"], "bar":["bar"]}
                 |

/sorte

  • [key:closure]?
    (optional) closure that returns the value to be used for sorting
  • (list|varname)
    the list to sort
  • ...(string|closure)? = (a b)
    (optional) the expression or closure used to compare two items a and b

Sorts a list.

The comparison closure must accept two named arguments which will be equivalent to a and b in the expression.

Using a comparison closure can be very performance and time intensive on longer lists.

If given a variable name, the variable will be modified.

See /lalib? expressions for more details on expressions.

Examples
stscript

/sorte [5,3,-10,-99,0] |
// returns [-99,-10,0,3,5] |
stscript

/let x [5,3,-10,-99,0] |
/sorte x |
/echo {{var::x}} |
// returns [-99,-10,0,3,5] |
stscript

/let x [5,3,-10,-99,0] |
/sorte {{var::x}} |
/echo {{var::x}} |
// returns [5,3,-10,-99,0] |
stscript

/sorte [5,3,-10,-99,0] (a  b) |
// returns [-99,-10,0,3,5] |
stscript

/sorte [5,3,-10,-99,0] (b  a) |
// returns [5,3,0,-10,-99] |
stscript

/sorte [5,3,-10,-99,0] {: a= b= /sub a b :} |
// returns [-99,-10,0,3,5] |

/flatten

  • [depth:number]? = 1
    (optional) The depth level specifying how deep a nested list structure should be flattened. Defaults to 1. Use 0 to flatten all levels.
  • (list)
    the list to flatten

Creates a new list with all sub-list elements concatenated into it recursively up to the specified depth.

Examples
stscript

/flatten [1, 2, 3, [4, 5, 6, [7, 8, 9]]] |
// returns [1, 2, 3, 4, 5, 6, [7, 8, 9]] |
stscript

/flatten depth=0 [1, 2, 3, [4, 5, 6, [7, 8, 9]]] |
// returns [1, 2, 3, 4, 5, 6, 7, 8, 9] |

/filter

  • (list|dictionary)
    the list or dictionary to iterate over
  • ...(closure|string)
    the closure or expression to execute for each item, with {{var::item}} and {{var::index}} placeholders

Executes command for each item of a list or dictionary and returns the list or dictionary of only those items where the command returned true.

See /lalib? expressions for more details on expressions.

Examples
stscript

/filter [1,2,3,4,5] {:
    /test left={{var::item}} rule=gt right=2
:} |
// returns [3, 4, 5] |
stscript

/filter [1,2,3,4,5] {: it=
    /test left={{var::it}} rule=gt right=2
:} |
// returns [3, 4, 5] |
stscript

/filter [1,2,3,4,5] (item > 2) |
// returns [3, 4, 5] |

/find

  • [index=true|false]? = false
    (optional) return the matching item's index instead of the item
  • [last=true|false]? = false
    (optional) return the last instead of the first matching item
  • (list|dictionary)
    the list or dictionary to iterate over
  • ...(closure|subcommand)
    the command to execute for each item, using {{var::item}} and {{var::index}} as placeholders

Executes the provided closure or expression for each item of a list or dictionary and returns the first item where the command returned true.

See /lalib? expressions for more details on expressions.

Examples
stscript

/find [1,2,3,4,5] {:
    /test left={{var::item}} rule=gt right=2
:} |
/echo |
// returns 3 |
stscript

/find [1,2,3,4,5] {: it=
    /test left={{var::it}} rule=gt right=2
:} |
/echo |
// returns 3 |
stscript

/find [1,2,3,4,5] (item > 2) | /echo |
// returns 3 |

/slice

  • [start:number]
    the starting index of the slice, negative numbers start from the back
  • [end:number]?
    (optional) the ending index of the slice (non-inclusive)
  • [length:number]?
    (optional) the length of the slice
  • (string|list)?
    (optional) the value to slice

Retrieves a slice of a list or string.

Examples
stscript

/slice start=2 length=3 [1,2,3,4,5,6] | /echo |
// returns [3,4,5] |
stscript

/slice start=-8 The quick brown fox jumps over the lazy dog | /echo |
// returns lazy dog |

/splice

  • [start:number]
    the starting index of the splice, negative numbers start from the back
  • [delete:number]?
    (optional) the number of elements to remove in the list from start (use delete= to remove everything)
  • [insert:list|string]?
    (optional) the elements to add at index start=
  • (string|number|bool|list|dictionary)?
    (optional) the list or string to operate on

Creates a new list with some elements removed and / or replaced at a given index.

Examples
stscript

/splice insert=[30, 40, 50] start=3 delete=3 [0,1,2,3,4,5,6] |
/echo |
// returns [0,1,2,30,40,50,6] |
stscript

/splice start=3 delete=3 [0,1,2,3,4,5,6] |
/echo |
// returns [0,1,2,6] |
stscript

/splice insert=100 start=3 [0,1,2,3,4,5,6] |
/echo |
// returns [0,1,2,100,3,4,5,6] |
``

Issues· 4 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言