> ## Documentation Index
> Fetch the complete documentation index at: https://docs.projectreal.gg/llms.txt
> Use this file to discover all available pages before exploring further.

# Closures

> Sprawdzaj, twórz, klonuj i wymieniaj zamknięcia.

<div className="real-category-page">
  Sprawdzaj, twórz, klonuj i wymieniaj zamknięcia.

  ## Dostępne funkcje

  <CardGroup cols={2}>
    <Card title="checkcaller" href="./checkcaller">
      Zwraca, czy current Luau thread znajduje się w Real caller context. Function nie przyjmuje arguments i pushuje boolean result z the current caller context. Function nie sprawdza Lua call stack ani function object.
    </Card>

    <Card title="clonefunction" href="./clonefunction">
      Creates and returns a separate function value for the function passed as the first argument. The argument must be a function.
    </Card>

    <Card title="comparefunctions" href="./comparefunctions">
      Porównuje dwa function values przez ich function identity. Oba arguments muszą być functions. Function zwraca boolean result z function identity(L, 1) == function identity(L, 2). Nie porównuje function bytecode, source, behavior, hashes, upvalues ani newcclosure mappings. comparefunction jest alias dla tej samej function.
    </Card>

    <Card title="getfunctionhash" href="./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.
    </Card>

    <Card title="hookfunction" href="./hookfunction">
      Hookuje target function przez replacement function i zwraca cloned copy original target closure. Oba arguments muszą być functions. Function najpierw flushuje pending C function swaps, robi cloning target przez function cloning, dodaje replacement closure albo jej mapped newcclosure target do hidden stack tracking, wywołuje FixCallstack dla target i cloned original, a potem patchuje target closure przez C closure, Luau closure albo newcclosure-specific path. Jeśli target nie jest jeszcze w hook records, cloned original jest tam zapisywany dla restorefunction. Returned function to cloned original closure.
    </Card>

    <Card title="hookmetamethod" href="./hookmetamethod">
      Wyszukuje metamethod function na value i hookuje tę function przez hookfunction. First argument może być dowolnym value akceptowanym przez raw metafield lookup. Second argument musi być string metamethod name, a third argument musi być function replacement. Jeśli raw metafield lookup nie znajdzie named metafield, function rzuca "Metamethod doesn't exist" dla argument 2. Jeśli metafield istnieje, ale nie jest function, rzuca "Metamethod isn't a function" dla argument 2. Gdy metafield jest function, hookmetamethod wywołuje hookfunction z found metamethod function jako target i zwraca cloned original closure z hookfunction.
    </Card>

    <Card title="iscclosure" href="./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.
    </Card>

    <Card title="isexecutorclosure" href="./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.
    </Card>

    <Card title="isfunctionhooked" href="./isfunctionhooked">
      Returns whether the provided function currently has a hook record. The argument must be a function.
    </Card>

    <Card title="ishiddenstack" href="./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.
    </Card>

    <Card title="islclosure" href="./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.
    </Card>

    <Card title="isnewcclosure" href="./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.
    </Card>

    <Card title="newcclosure" href="./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.
    </Card>

    <Card title="newlclosure" href="./newlclosure">
      Returns a Luau closure that calls the provided function. The first argument must be a function.
    </Card>

    <Card title="restorefunction" href="./restorefunction">
      Przywraca lub zastępuje function przez wewnętrzne wywołanie function hook operation i nie zwraca żadnych values. First argument musi być function. Przy jednym function argument function wyszukuje the saved original function; jeśli entry nie istnieje, zgłasza "Function is not hooked". Następnie wywołuje function hook operation z hooked closure i stored original closure, czyści Lua stack i usuwa restored closure z hook records, gdy użyto stored original. Jeśli second argument też jest function, function traktuje firstFunction jako original function do zainstalowania, a secondFunction jako closure do patchowania. W tej formie nie jest wykonywany missing-original check wobec zapisanej wartosci hook records; zapisana wartosc jest tylko porownywana podczas final remove check. Non-function second arguments są ignorowane przez branch condition. restorefunc i restoreclosure są aliases tej samej function.
    </Card>

    <Card title="sethiddenstack" href="./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.
    </Card>
  </CardGroup>
</div>
