Skip to main content
Inspeccione, cree, clone y reemplace cierres.

Funciones disponibles

checkcaller

Devuelve si el current Luau thread está presente en Real caller context. La function no toma arguments y empuja el boolean result de the current caller context. La function no inspecciona el Lua call stack ni un function object.

clonefunction

Creates and returns a separate function value for the function passed as the first argument. The argument must be a function.

comparefunctions

Compara dos function values por su function identity. Ambos arguments deben ser functions. La function devuelve el boolean result de function identity(L, 1) == function identity(L, 2). No compara function bytecode, source, behavior, hashes, upvalues ni newcclosure mappings. comparefunction es un alias de la misma function.

getfunctionhash

Returns an uppercase SHA384 hex digest derived from a Luau function. The argument must be a function, and C closures raise “Lua function expected”. If no hashable function content is available, the function returns nil.

hookfunction

Hace hook de una target function con una replacement function y devuelve una cloned copy de la original target closure. Ambos arguments deben ser functions. La function primero hace flush de pending C function swaps, clona el target mediante function cloning, agrega la replacement closure o su mapped newcclosure target a hidden stack tracking, llama a FixCallstack para target y cloned original, y luego parchea la target closure mediante el C closure, Luau closure o newcclosure-specific path. Si target aún no está en hook records, el cloned original se guarda allí para restorefunction. La returned function es la cloned original closure.

hookmetamethod

Busca una metamethod function en un value y hace hook de esa function mediante hookfunction. El first argument puede ser cualquier value aceptado por raw metafield lookup. El second argument debe ser un string metamethod name, y el third argument debe ser una function replacement. Si raw metafield lookup no encuentra el named metafield, la function genera “Metamethod doesn’t exist” para argument 2. Si el metafield existe pero no es una function, genera “Metamethod isn’t a function” para argument 2. Cuando el metafield es una function, hookmetamethod llama a hookfunction con la found metamethod function como target y devuelve la cloned original closure de hookfunction.

iscclosure

Returns whether the provided function is a C closure. The argument must be a function; passing any other type raises a type error. The function does not inspect executor ownership, source, bytecode, or upvalues.

isexecutorclosure

Returns whether the provided function is classified as executor-owned. The argument must be a function. The function does not inspect source text, debug names, bytecode hashes, or call stack ownership.

isfunctionhooked

Returns whether the provided function currently has a hook record. The argument must be a function.

ishiddenstack

Returns whether a function, or the function at a stack level, is marked as hidden. target must be a function or stack level number. Invalid stack levels raise “Level out of range”. isstackhidden is an alias.

islclosure

Returns whether the provided function is a Lua closure. The argument must be a function; passing a non-function raises a type error. isluaclosure is an alias.

isnewcclosure

Returns whether the provided function is a newcclosure-created C closure. The first argument must be a function; passing a non-function raises a type error. Documented usage is a single function argument; extra arguments are not part of the supported signature.

newcclosure

Returns a C closure for the provided function. If the function is already a C closure, the same function is returned. Passing a non-function raises a type error.

newlclosure

Returns a Luau closure that calls the provided function. The first argument must be a function.

restorefunction

Restaura o reemplaza una function llamando internamente a function hook operation y no devuelve values. El first argument debe ser una function. Con un solo function argument, la function busca the saved original function; si no existe entry, genera “Function is not hooked”. Luego llama a function hook operation con la hooked closure y la stored original closure, limpia el Lua stack y elimina la restored closure de hook records cuando se usó la stored original. Si el second argument también es una function, la function trata firstFunction como la original function que se instalará y secondFunction como la closure que se parcheará. En esa forma, no se realiza ningun missing-original check contra el valor almacenado en hook records; el valor almacenado solo se compara durante el final remove check. Los non-function second arguments son ignorados por la branch condition. restorefunc y restoreclosure son aliases de la misma function.

sethiddenstack

Marks or unmarks a function, or the function at a stack level, as hidden. target must be a function or stack level number. hidden defaults to true. Invalid stack levels raise “Level out of range”. setstackhidden is an alias.