脚本、字节码和环境查询。
可用函数
decompile
对 Roblox script 执行 decompile,并在 bytecode 可用时返回生成的 source text。argument 必须是受支持的 script Instance。如果没有可用的 bytecode,该 function 返回 nil。
dumpstring
返回 Roblox script object 的 decompressed bytecode string。dumpstring 注册到与 getscriptbytecode 相同的 C++ function,因此行为完全相同。argument 必须是 object。共享的 bytecode reader 接受 ClassName 值 ModuleScript、LocalScript、CoreScript 和 Script。对于 Script,RunContext 必须是 Client。如果缺少 ClassName,function 抛出 “Invalid Instance”。如果 ClassName 不是受支持的 script class,则抛出 “Script expected”。如果该值是其他 RunContext 的 Script,则抛出 “Expected a Script with RunContext set to Client”。如果 embedded bytecode reference 无效,或 stored bytecode 长度为 8 bytes 或更少,function 返回 nil。否则,它会用 DecompressBytecode 解压 stored bytecode,并把 resulting bytes 作为 Luau string 返回。Hash mismatch、too-short compressed data 或 ZSTD decompression errors 会由 DecompressBytecode 作为 error text bytes 返回,而不是在这里抛出。
getcallingscript
返回 current Luau thread object 上存储的 script。function 不接受 arguments。它读取 the current thread script,这是一个 stored reference。如果该 stored reference 未 expired,function 会用 Instance cache push script Instance 并返回它。如果 stored reference expired,function 返回 nil。function 不检查 Lua call stack,不搜索 ancestor scripts,也不检查 script ClassName。
getinstancesbyclass
从 Instance cache table 返回 ClassName field 与请求 string 完全匹配的 instances。第一个参数通过 string type checking 读取。empty string 会抛出 “ClassName required”。function 创建新的 array table,遍历存储在 Instance cache 下的 cache,只保留 Lua type 为 object 的 values,读取每个 object value 的 ClassName field,并用 strcmp 与请求的 className 比较。matches 从 index 1 开始 sequential 插入。匹配是 exact 且 case-sensitive。function 不使用 IsA,不包含 subclasses,不 walk descendants,不按 Parent filter,也不 sort result。getinstancesofclass 是同一 function 的 alias。
getloadedmodules
Returns a new array table containing live entries from loaded module list. The optional excludeCore argument is read with optional boolean handling and defaults to true when omitted or nil. If excludeCore is true, entries whose instance is a descendant of core packages or CoreGui are skipped. Expired weak entries and locked stored references without a value are skipped. The function pushes each remaining entry with Instance cache at sequential array indexes starting at 1. The function does not check ClassName, does not sort the result, and does not walk the DataModel.
getmenv
Returns the environment table associated with a ModuleScript. The argument must be a ModuleScript object. Invalid objects raise “Invalid Instance”, non-ModuleScript objects raise “ModuleScript expected”, and ModuleScripts without an available thread raise “invalid thread”. The function does not accept Script or LocalScript; use getsenv for those cases.
getreferencedby
Returns cached Instance values whose supported reference properties point to the provided Instance. The argument must be an Instance.
getrunningscripts
返回一个新的 array table,其中包含来自 live Lua threads 的 unique script Instances。该 function 不接受 arguments。它遍历 the live Luau thread list,读取每个 thread node,并跳过没有 thread node、没有 weak thread ref、没有 LiveLuaRef、没有 Lua state、没有 object 或带有 expired Script stored reference 的 entries。对于每个剩余 thread,它会 lock scriptThread->object->Script(),按 script reference 去重,使用 Instance cache 推入 Instance,并从 1 开始插入连续 array indexes。function 不扫描 DataModel,不检查 ClassName,也不排序 result。
getscriptbytecode
返回 Roblox script object 的 decompressed bytecode string。getscriptbytecode 注册到与 dumpstring 相同的 C++ function,因此行为完全相同。argument 必须是 object。共享的 bytecode reader 接受 ClassName 值 ModuleScript、LocalScript、CoreScript 和 Script。对于 Script,RunContext 必须是 Client。如果缺少 ClassName,function 抛出 “Invalid Instance”。如果 ClassName 不是受支持的 script class,则抛出 “Script expected”。如果该值是其他 RunContext 的 Script,则抛出 “Expected a Script with RunContext set to Client”。如果 embedded bytecode reference 无效,或 stored bytecode 长度为 8 bytes 或更少,function 返回 nil。否则,它会用 DecompressBytecode 解压 stored bytecode,并把 resulting bytes 作为 Luau string 返回。Hash mismatch、too-short compressed data 或 ZSTD decompression errors 会由 DecompressBytecode 作为 error text bytes 返回,而不是在这里抛出。
getscriptclosure
Loads the stored bytecode for a supported Roblox script Instance and returns it as a Lua closure. Returns nil when usable bytecode is not available.
getscripthash
返回 Roblox script object 的 stored bytecode string 的 uppercase SHA384 hex digest。argument 必须是 object。共享 bytecode reader 接受 ClassName 值 ModuleScript、LocalScript、CoreScript 和 Script。对于 Script,RunContext 必须是 Client。如果缺少 ClassName,function 会抛出 “Invalid Instance”。如果 ClassName 不是受支持的 script classes 之一,会抛出 “Script expected”。如果该值是另一个 RunContext 的 Script,会抛出 “Expected a Script with RunContext set to Client”。如果 embedded bytecode reference 无效,或 stored bytecode 长度为 8 bytes 或更少,function 返回 nil。否则,它会对确切的 stored bytecode bytes 计算 SHA384,并返回 uppercase hex string。function 不调用 DecompressBytecode,也不会对 decompressed bytecode 计算 hash。
getscripts
返回当前存在于 Instance cache 中的 script object 值。该 function 不接受 arguments。它遍历存储在 Instance cache 下的 cache,并且只处理 value 是 object 的 entries。它用 optional string handling 读取每个 value 的 ClassName field。LocalScript 和 ModuleScript entries 会被包含。Script entries 只有在其 RunContext offset 等于 CLIENT 或 PLUGIN 时才会被包含。其他 ClassName 值、没有 string ClassName 的 entries,以及 CoreScript entries 会被跳过。结果是 sequential Luau table。function 不遍历 DataModel,也不保证 sorted order。
getscriptthread
当 Real 可以找到时,返回与 script object 关联的 Lua thread。argument 必须是 object。该 function 会读取该值的 ClassName field,如果该 field 不是 string,会抛出 “not a valid Instance”。接受的 ClassName 值是 Script、LocalScript 和 ModuleScript;任何其他值都会抛出 “Script expected”。它首先通过 script reference 检查 Real 的 ScriptThreadCache。cache hit 时,返回缓存的 Luau thread 作为 thread。cache miss 时,Script 值必须具有 RunContext Client,否则 function 会抛出 “Expected a Script with RunContext set to Client”。然后它遍历 the live Luau thread list,沿着每个 thread node 的 first weak thread reference 到 LiveLuaRef,跳过 missing thread data 或 expired Script stored references,并将每个 script reference 与请求的 script 比较。如果找到 match,则返回该 Luau thread 作为 thread。如果没有找到 match,则返回 nil。
getsenv
Returns the environment table associated with a LocalScript, Script, or ModuleScript. Unsupported script objects or scripts without an available thread raise the same errors as the underlying script lookup.
loadstring
Compiles a Luau source string and returns the loaded function. If loading fails, it returns nil and an error message. The returned function is not executed automatically.