Skip to main content
فحص وإنشاء واستنساخ واستبدال عمليات الإغلاق.

الدوال المتاحة

checkcaller

تعيد ما إذا كان current Luau thread موجودا في Real caller context. لا تأخذ function أي arguments وتدفع boolean result الخاص بـ the current caller context. لا تفحص function Lua call stack أو 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

تقارن function values اثنين عبر function identity الخاص بهما. يجب أن يكون كلا arguments من type functions. تعيد function قيمة boolean result الخاصة بـ function identity(L, 1) == function identity(L, 2). لا تقارن function bytecode أو source أو behavior أو hashes أو upvalues أو newcclosure mappings. comparefunction هو alias لنفس 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

تعمل hook لـ target function باستخدام replacement function وتعيد cloned copy من original target closure. يجب أن يكون كلا arguments من type functions. تبدأ function بعمل flush لـ pending C function swaps، ثم cloning للـ target عبر function cloning، وتضيف replacement closure أو mapped newcclosure target الخاص بها إلى hidden stack tracking، وتستدعي FixCallstack للـ target و cloned original، ثم تعمل patch للـ target closure عبر C closure أو Luau closure أو newcclosure-specific path. إذا لم يكن target موجودا في hook records، يتم تخزين cloned original هناك من أجل restorefunction. returned function هي cloned original closure.

hookmetamethod

تبحث عن metamethod function على value وتعمل hook لتلك function عبر hookfunction. يمكن أن يكون first argument أي value يقبلها raw metafield lookup. يجب أن يكون second argument عبارة عن string metamethod name، ويجب أن يكون third argument عبارة عن function replacement. إذا لم يجد raw metafield lookup الـ named metafield، ترفع function “Metamethod doesn’t exist” للـ argument 2. إذا كان metafield موجودا لكنه ليس function، ترفع “Metamethod isn’t a function” للـ argument 2. عندما يكون metafield عبارة عن function، تستدعي hookmetamethod hookfunction باستخدام found metamethod function كـ target وتعيد cloned original closure الخاصة بـ 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

تستعيد أو تستبدل function عبر استدعاء function hook operation داخليا ولا تعيد أي values. يجب أن يكون first argument من type function. مع function argument واحد، تبحث function عن the saved original function؛ إذا لم يوجد entry فإنها ترفع “Function is not hooked”. ثم تستدعي function hook operation مع hooked closure و stored original closure، وتمسح Lua stack، وتزيل restored closure من hook records عندما تم استخدام stored original. إذا كان second argument أيضا function، فإن function تعامل firstFunction كـ original function المراد تثبيتها و secondFunction كـ closure المراد patch لها. في هذا الشكل، لا يتم إجراء missing-original check على قيمة hook records المخزنة؛ تتم مقارنة القيمة المخزنة فقط أثناء final remove check. يتم تجاهل non-function second arguments بواسطة branch condition. restorefunc و restoreclosure هما aliases لنفس 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.