Library of STScript commands.
- Boolean Operations (test, and, or, not)
- List Operations (foreach, map, filter, find, slice, shuffle, dict)
- Split & Join (split, join)
- Text Operations (trim, replace, replaceAll, diff, json-pretty)
- Accessing & Manipulating Structured Data (getat, setat)
- Exception Handling (try, catch)
- Copy & Download (copy, download)
- DOM Interaction (dom)
- Group Chats (memberpos)
- Conditionals - switch (switch, case)
- Conditionals - if (ife, elseif, else, then)
- World Info (wi-list-books, wi-list-entries)
- Costumes / Sprites (costumes)
- Quick Replies (qr-edit, qr-add)
- Chat Messages (swipes-get, swipes-list, swipes-count, swipes-index, swipes-add, swipes-del, swipes-go, swipes-swipe, message-edit)
- Time & Date (timestamp)
- Async (fireandforget)
- Costumes Plugin for
/costumes
command.
Lists LALib commands
/lalib?
left=val rule=rule right=val
Returns true or false, depending on whether left and right adhere to rule. Available rules: gt => a > b, gte => a >= b, lt => a < b, lte => a <= b, eq => a == b, neq => a != b, not => !a, in (strings) => a includes b, nin (strings) => a not includes b
/setvar key=x 1 |
/setvar key=y 2 |
/test left={{getvar::x}} rule=eq right={{getvar::y}} |
/echo The result will be "false": {{pipe}}
/setvar key=x 1 |
/setvar key=y 2 |
/test left={{getvar::x}} rule=lt right={{getvar::y}} |
/echo The result will be "true": {{pipe}}
left=val right=val
Returns true if both left and right are true, otherwise false.
/and left=true right=false |
/echo The result will be "false": {{pipe}}
/and left=true right=true |
/echo The result will be "true": {{pipe}}
left=val right=val
Returns true if at least one of left and right are true, false if both are false.
/or left=true right=false |
/echo The result will be "true": {{pipe}}
/or left=false right=false |
/echo The result will be "false": {{pipe}}
(value)
Returns true if value is false, otherwise true.
/not true |
/echo The result will be "false": {{pipe}}
/not false |
/echo The result will be "true": {{pipe}}
[optional list=[1,2,3]] [optional var=varname] [optional globalvar=globalvarname] (/command {{item}} {{index}})
Executes command for each item of a list or dictionary.
/setvar key=x ["A", "B", "C"] |
/foreach var=x
/echo Item {{index}} is {{item}} \|
/delay 400
/foreach list={"a":"foo","b":"bar"}
/echo Item {{index}} is {{item}} \|
/delay 400
[optional list=[1,2,3]] [optional var=varname] [optional globalvar=globalvarname] (/command {{item}} {{index}})
Executes command for each item of a list or dictionary and returns the list or dictionary of the command results.
/setvar key=x [1,2,3] |
/map var=x
/mul {{item}} {{item}}
|
/echo Squares: {{pipe}}
/map list={"a":"foo","b":"bar"}
/return This is item {{index}} with value {{item}}
|
/echo
[optional list=[1,2,3]] [optional var=varname] [optional globalvar=globalvarname] (/command {{item}} {{index}})
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.
/setvar key=x [1,2,3,4,5,6,7,8,9,10] |
/filter var=x
/mod {{item}} 2 \|
/test left=\{\{pipe\}\} rule=eq right=0
|
/echo Only even numbers: {{pipe}}
/filter list={"a":"foo","b":"bar"}
/test left={{item}} rule=in right=a
|
/echo Only items that include an "a": {{pipe}}
[optional list=[1,2,3]] [optional var=varname] [optional globalvar=globalvarname] (/command {{item}} {{index}})
Executes command for each item of a list or dictionary and returns the first item where the command returned true.
/setvar key=x [2,4,6,8,10] |
/find var=x
/test left={{item}} rule=gt right=5
|
/echo The first item greater than 5: {{pipe}}
/find list={"a":"foo","b":"bar","c":"foobar","d":"barfoo"}
/len {{item}} \|
/test left=\{\{pipe\}\} rule=gt right=3
|
/echo The first item longer than 3 characters: {{pipe}}
start=int [optional end=int] [optional length=int] [optional var=varname] [optional globalvar=globalvarname] (optional value)
Retrieves a slice of a list or string.
/setvar key=x [1,2,3,4,5] |
/slice var=x start=2 |
/echo The result will be "[3,4,5]": {{pipe}}
/slice start=-3 foo bar |
/echo The result will be "bar": {{pipe}}
(list to shuffle)
Returns a shuffled list.
/shuffle [1,2,3,4,5] |
/echo
[optional var=varname] [optional globalvar=globalvarname] (list of lists)
Takes a list of lists (each item must be a list of at least two items) and creates a dictionary by using each items first item as key and each items second item as value.
/setvar key=x [
["a", 1],
["b", 2],
["c", 3]
] |
/dict var=x |
/echo
[optional find=","] [optional trim=true|false] [optional var=varname] [optional globalvar=globalvarname] (value)
Splits value into list at every occurrence of find. Supports regex find=/\s/
/split foo, bar |
/echo The result will be ["foo", "bar"]: {{pipe}}
/split find=/o.+?o/g The quick brown fox jumps over the lazy dog. |
/echo The result will be ["The quick br", "x jumps", "g."]: {{pipe}}
[optional glue=", "] [optional var=varname] [optional globalvar=globalvarname] (optional list)
Joins the items of a list with glue into a single string. Use glue={{space}}
to join with a space.
/setvar key=x ["a","b","c"] |
/join var=x |
/echo The result will be "a, b, c": {{pipe}}
/join glue=::: ["foo", "bar"] |
/echo The result will be "foo:::bar": {{pipe}}
(text to trim)
Removes whitespace at the start and end of the text.
/return [" foo", "bar "] |
/getat index=0 |
/trim |
/echo
[find=string_or_regex] [replace=string] [optional var=varname] [optional globalvar=globalvarname] (optional value)
Replaces the first occurrence of "find" with "replace" in the given value or variable.
/replace find="cat" replace="dog" The cat sat on the mat |
/echo The result will be "The dog sat on the mat": {{pipe}}
/setvar key=sentence There are 123 apples |
/replace find="/\d+/" replace="NUMBER" var=sentence |
/echo The result will be "There are NUMBER apples": {{pipe}}
[find=string_or_regex] [replace=string] [optional var=varname] [optional globalvar=globalvarname] (optional value)
Replaces all occurrences of "find" with "replace" in the given value or variable.
/replaceAll find="apple" replace="orange" I like apples and apple pie |
/echo The result will be "I like oranges and orange pie": {{pipe}}
/setvar key=sentence This is a test sentence |
/replaceAll find="/[aeiou]/g" replace="-" var=sentence |
/echo The result will be "Th-s -s - t-st s-nt-nc-": {{pipe}}
[optional all=true] [optional buttons=true] [optional stripcode=true] [optional notes=text] [old=oldText] [new=newText]
Compares old text vs new text and displays the difference between the two. Use all=true
to show new, old, and diff side by side. Use buttons=true
to add buttons to pick which text to return. Use stripcode=true
to remove all codeblocks before diffing. Use notes="some text"
to show additional notes or comments above the comparison.
/echo comparing the last two messages |
/sub {{lastMessageId}} 1 |
/messages names=off |
/split find=``` |
/getat index=-1 |
/let old {{pipe}} |
/setvar key=old {{var::old}} |
/messages names=off {{lastMessageId}} |
/split find=``` |
/getat index=-1 |
/let new {{pipe}} |
/setvar key=new {{var::new}} |
/diff old={{var::old}} new={{var::new}}
/diff old="The quick brown fox jumps over the lazy dog." new="The fast spotted fox jumps across the sleeping dog." notes="Foxes and dogs." all=true
(JSON)
Pretty print JSON.
/json-pretty {"a":1, "b":[1,2,3]} |
/send ```json{{newline}}{{pipe}}{{newline}}```
index=int|fieldname|list [optional var=varname] [optional globalvar=globalvarname] (optional value)
Retrieves an item from a list or a property from a dictionary.
/setvar key=x {
"a": [
1,
2,
{
"b": "foo",
"c": "bar"
}
],
"d": "D"
} |
/getat var=x index=d |
/echo The result will be "D": {{pipe}}
/return {
"a": [
1,
2,
{
"b": "foo",
"c": "bar"
}
],
"d": "D"
} |
/getat index=["a", 2, "b"] |
/echo The result will be "foo": {{pipe}}
/return {
"a": [
1,
2,
{
"b": "foo",
"c": "bar"
}
],
"d": "D"
} |
/getat index=a |
/getat index=2 |
/getat index=c |
/echo The result will be "bar": {{pipe}}
index=int|fieldname|list [optional var=varname] [optional globalvar=globalvarname] [optional value=list|dictionary] (value)
Sets an item in a list or a property in a dictionary. Example: /setat value=[1,2,3] index=1 X
returns [1,"X",3]
, /setat var=myVariable index=[1,2,"somePropery"] foobar
sets the value of myVariable[1][2].someProperty
to "foobar" (the variable will be updated and the resulting value of myVariable will be returned). Can be used to create structures that do not already exist.
/setvar key=x {
"a": [
1,
2,
{
"b": "foo",
"c": "bar"
}
],
"d": "D"
} |
/setat var=x index=d new value for D |
/echo {{getvar::x}}
/setvar key=x {
"a": [
1,
2,
{
"b": "foo",
"c": "bar"
}
],
"d": "D"
} |
/setat var=x index=["a", 2, "c"] new value for bar |
/echo {{getvar::x}}
/flushvar x |
/setat var=x index=["a","b",2] creating new objects or list |
/echo {{getvar::x}}
(command)
try catch.
/echo Try this first while being connected to an LLM, then without a connection. |
/setvar key=myPrompt Say hello! |
/try
/getvar myPrompt \|
/gen \{\{pipe}}
|
/catch pipe={{pipe}}
/echo something went wrong: {{error}} \|
/return "gen failed :("
|
/echo {{pipe}}
[pipe={{pipe}}] (command)
try catch. You must always set pipe={{pipe}}
and /catch must always be called right after /try. Use {{exception}}
or {{error}}
to get the exception's message.
see /try
(value)
Copies value into clipboard.
/copy this text is now in your clipboard
/copy {{lastMessage}}
[optional name=filename] [optional ext=extension] (value)
Downloads value as a text file.
/download Let's download this text.
/download name=TheLastMessage ext=md {{lastMessage}}
[action=click|value|property] [optional value=newValue] [optional property=propertyName] [optional attribute=attributeName] (CSS selector)
Click on an element, change its value, retrieve a property, or retrieve an attribute. To select the targeted element, use CSS selectors. Example: /dom action=click #expandMessageActions
or /dom action=value value=0 #avatar_style
/dom action=click #fast_ui_mode |
/echo Toggled "No Blur Effect" setting
/dom action=value value=0 #avatar_style |
/echo Avatar style has been set to "Circle"
/dom action=property property=value #avatar_style |
/echo Current avatar style: {{pipe}}
/dom action=attribute attribute=is_system #chat > .mes:last-child |
/echo Is the last message a system message? {{pipe}}
(name) (position)
Move group member to position (index starts with 0).
/memberpos Alice 3 |
/echo Alice has been moved to position 3
[optional var=varname] [optional globalvar=globalvarname] (optional value)
Use with /case.
/setvar key=x foo |
/switch var=x |
/case pipe={{pipe}} value=1 /echo value is one |
/case pipe={{pipe}} value=foo /echo value is foo |
/case pipe={{pipe}} value=bar /echo value is bar |
/echo done
[pipe={{pipe}}] [value=comparisonValue] (/command)
Execute command and break out of the switch if the value given in /switch matches the value given here.
see /switch
(/command)
Use with /then, /elseif, and /else. The provided command must return true or false.
/setvar key=x foo |
/ife /test left=x rule=eq right=1 |
/then pipe={{pipe}} /echo value is one |
/elseif pipe={{pipe}} /test left=x rule=eq right=foo |
/then pipe={{pipe}} /echo value is foo |
/elseif pipe={{pipe}} /test left=x rule=eq right=bar |
/then pipe={{pipe}} /echo value is bar |
/else pipe={{pipe}} /echo value is something else
[pipe={{pipe}}] (/command)
Use with /ife, /then, and /else. The provided command must return true or false.
see /ife
[pipe={{pipe}}] (/command)
Use with /ife, /elseif, and /then. The provided command will be executed if the previous /if or /elseif was false.
see /ife
[pipe={{pipe}}] (/command)
Use with /ife, /elseif, and /else. The provided command will be executed if the previous /if or /elseif was true.
see /ife
[optional source=true]
Get a list of currently active World Info books. Use source=true
to get a dictionary of lists where the keys are the activation sources.
/wi-list-books |
/echo The currently active WI books are: {{pipe}}
/wi-list-books source=true |
/json-pretty |
/comment Currently active WI books:{{newline}}```json{{newline}}{{pipe}}{{newline}}```
[optional flat=true] (optional book name)
Get a list of World Info entries from currently active books or from the book with the provided name. Use flat=true
to list all entries in a flat list instead of a dictionary with entries per book.
/wi-list-entries |
/map list={{pipe}}
/getat index=entries {{item}} \|
/map list=\{\{pipe\}\}
/getat index=comment \\{\\{item\\}\\}
|
/echo Overview of WI entries in currently active books: {{pipe}}
[optional recurse=false] (folder)
Get a list of costume / sprite folders, recursive by default.
/costumes Alice | /echo Alice's costumes: {{pipe}}
/costumes Alice/Winter | /echo Alice's winter costumes: {{pipe}}
/costumes recurse=false Alice | /echo Alice's top-level costumes only: {{pipe}}
[optional set=qrSetName] [optional label=qrLabel] (optional qrLabel)
Show the Quick Reply editor. If no QR set is provided, tries to find a QR in one of the active sets.
/qr-edit My QR From An Active Set
/qr-edit set=MyQrSet label=MyQr
[optional set=qrSetName] [optional label=qrLabel] (optional qrLabel)
Create a new Quick Reply and open its editor. If no QR set is provided, tries to find a QR in one of the active sets.
/qr-add New QR In Active Set
/qr-add set=MyQrSet label=MyNewQr
[optional message=messageId] (index)
Get the n-th swipe (zero-based index) from the last message or the message with the given message ID.
/swipes-get 5 |
/echo Swipe number five: {{pipe}}
/sub {{lastMessageId}} 2 |
/swipes-countget message={{pipe}} 5 |
/echo swipe number five: {{pipe}}
[optional message=messageId]
Get a list of all swipes from the last message or the message with the given message ID.
/swipes-list |
/echo
/sub {{lastMessageId}} 2 |
/swipes-list message={{pipe}} |
/echo
[optional message=messageId]
Get the number of all swipes from the last message or the message with the given message ID.
/swipes-count |
/echo
/sub {{lastMessageId}} 2 |
/swipes-count message={{pipe}} |
/echo
[optional message=messageId]
Get the current swipe index from the last message or the message with the given message ID.
/swipes-index |
/echo
/sub {{lastMessageId}} 2 |
/swipes-index message={{pipe}} |
/echo
(message)
Add a new swipe to the last message.
/sendas name=Alice foo |
/delay 1000 |
/swipes-add bar
(optional index)
Delete the current swipe or the swipe at index (0-based).
/sendas name=Alice foo |
/delay 1000 |
/swipes-add bar |
/delay 1000 |
/swipes-del
/sendas name=Alice foo |
/delay 1000 |
/swipes-add bar |
/delay 1000 |
/swipes-add foobar |
/delay 1000 |
/swipes-del 0
(index)
Go to the swipe. 0-based index.
/sendas name=Alice foo |
/delay 1000 |
/swipes-add bar |
/delay 1000 |
/swipes-add foobar |
/delay 1000 |
/swipes-go 0
Trigger a new swipe on the current message.
/swipes-swipe |
/echo swiping has finished
[optional message=messageId] [optional append=true] (new text)
Edit the current message or the message at the provided message ID. Use append=true
to add the provided text at the end of the message. Use {{space}}
to add space at the beginning of the text.
/sendas name=Alice foo |
/delay 1000 |
/message-edit bar
/sendas name=Alice foo |
/delay 1000 |
/message-edit append=true bar
Returns the number of milliseconds midnight at the beginning of January 1, 1970, UTC.
/timestamp |
/echo
(command)
Execute a command without waiting for it to finish.
/fireandforget
/delay 1000 \|
/echo firing \|
/delay 1000 \|
/echo still firing
|
/echo outside
(url)
UNDOCUMENTED
/fetch http://example.com |
/echo
[optional query=cssSelector] [optional take=property] [optional call=property] (html)
UNDOCUMENTED
/fetch http://example.com |
/$ query=h1 take=textContent |
/echo
[optional query=cssSelector] [optional take=property] [optional call=property] (html)
UNDOCUMENTED
/fetch http://example.com |
/$$ query=p call=remove |
/echo