> ## 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.

# getproto

> Returns a nested Lua function by one-based index. target must be a Lua function or stack level number. Invalid stack levels raise "Level out of range", non-Lua functions raise "Lua function expected", and indexes outside the nested function range raise "index out of bounds". When active is true, returns currently live closures for that nested function instead. debug.getproto is an alias.

<div className="real-function-page">
  ```lua theme={null}
  getproto(target: function | number, index: number, active?: boolean): function | table
  ```

  ## Алиасы

  * `debug.getproto`

  ## Аргументы

  <ParamField path={"target"} type={"function | number"} required>
    Lua function or stack level whose nested functions are inspected.
  </ParamField>

  <ParamField path={"index"} type={"number"} required>
    One-based nested function index.
  </ParamField>

  <ParamField path={"active"} type={"boolean"}>
    When true, returns live closures for the selected nested function instead of a standalone function.
  </ParamField>

  ## Возвраты

  <ResponseField name={"proto"} type={"function | table"}>
    Nested function when active is false or omitted, or a table of live closures when active is true.
  </ResponseField>

  ## Пример

  Read a nested Proto as a cloned closure, or list live closures for that nested Proto.

  ```lua theme={null}
  local function outer()
      local function inner()
          return "ready"
      end

      return inner
  end

  local proto = getproto(outer, 1)
  local active = getproto(outer, 1, true)

  print(type(proto))
  print(#active)
  print(type(debug.getproto(outer, 1)))
  ```
</div>
