Script APIs
Functions
loadstring
function loadstring(source: string, chunk_name?: string)
Equivalent to Lua 5.1's loadstring. This function may access the thread's global environment (getfenv(0)) to resolve/cache imports and builtins.
checkcaller
bool checkcaller()
Returns true if the current thread is owned by Synapse.
checkcallstack
bool checkcallstack(type: string, level?: int = 2)
Returns true if the current thread is owned by Synapse AND all functions at or above level in the call stack are Synapse functions.
A level of 1 represents the function calling checkcallstack, 2 represents the function calling the function calling checkcallstack, and so forth.
issynapsefunction
bool issynapsefunction(f: function)
Returns true if f is a Synapse function.
islclosure
bool islclosure(f: function)
Returns true if f is a Lua function (as opposed to a C function).
decompile
string decompile(target: variant<function, LuaSourceContainer>, options?: table) [yields]
Decompiles target asynchronously. target cannot be a Synapse function.
The following options can be used:
| Option | Description | Default |
|---|---|---|
| VerboseFunctions | Adds a comment to functions with their name and optionally other info | true |
| FunctionLine | Adds the line that a function is defined | true |
| FunctionUpvalues | Lists the upvalues of functions | true |
| FunctionConstants | Lists the constants that functions use | false |
| RenameLoopVariables | Gives for loop variables more specific names if possible | true |
| VariableRenaming | Gives some variables contextual names | true |
| ExtraRenaming | Renames extra variables | true |
| NullableNaming | Allows variable renaming to ignore nil assignments | true |
| PrimitiveRenaming | Renames variables with trivial primitive types | true |
| Semicolons | Adds semicolons to the end of each statement | true |
| TableNewlines | Adds a newline after each table entry | true |
| UseIfElseExpression | Allows the use of if-else expression | false |
| CallLineInfo | Adds a comment next to function calls of their line | false |
| LazyFlattening | Try to less aggressively condense expressions | true |
| FormatNamecallChains | Adds extra newlines in between chained namecalls | false |
| FlattenGuardStatements | Turns guard statements into single lines | true |
| MaxCustomNameLength | Max length for variable names | 32 |
| MaxTabs | Max number of tabs | 20 |
| MaxRationalDenominator | Max denominator for rationalization | 1000 |
| DeduplicationThreshold | Threshold for string deduplication | 10000 |
getscriptthread
thread getscriptthread(script: Instance)
Returns the main Lua thread associated with script. Note that this may not be the only thread used!
getsenv
table getsenv(script: Instance)
Returns the Lua environment (such as that returned by getfenv) associated with the main function of script.
Essentially equivalent to getfenv(getscriptfunction(script)).
WARNING: Scripts may add a metatable to this value and check who's accessing it! If you want to get around this, check for whether the environment has a metatable and use syn.trampoline_call accordingly.
getscriptfunction
function getscriptfunction(script: Instance)
Returns the main function associated with script.
getscripthash
string getscripthash(script: LuaSourceContainer)
Returns a script's bytecode hash.
getfunctionhash
string getfunctionhash(script: function)
Returns a Lua function's bytecode hash.
getscriptname
string getscriptname(script: Instance)
Returns the name of a script when it was first loaded.
dumpbytecode
string dumpbytecode(target: variant<function, LuaSourceContainer>)
Dumps a function or script to the Luau bytecode format. target cannot be a Synapse function.
getcallingscript
variant<Instance, nil> getcallingscript()
Returns the script associated with the current thread or nil.
issynapsethread
bool issynapsethread(thread: thread)
Returns true if thread is owned by Synapse.
setsynapsethread
void setsynapsethread(set_to_synapse: bool, target_thread?: thread = nil)
Changes whether target_thread (or the current thread if target_thread is nil) can pass through checkcaller. If this is not the case, Synapse-specific overrides like game.HttpGet or Connection.Enabled will not work.