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

# getconstants

> Returns constants from a Lua function or stack level as a table keyed by one-based constant index. target must be a function or stack level number. Invalid stack levels raise "Level out of range". Non-function and non-number targets raise a type error expecting "function or number". C closures raise "Lua function expected". Nil, function, and table constants are absent from the returned table. debug.getconstants is an alias.

<div className="real-function-page">
  ```lua theme={null}
  getconstants(target: function | number): table
  ```

  ## エイリアス

  * `debug.getconstants`

  ## 引数

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

  ## 戻り値

  <ResponseField name={"constants"} type={"table"}>
    Table keyed by one-based constant indices. Indices for nil, function, and table constants are absent.
  </ResponseField>

  ## 例

  Read the Proto constants table for a Lua closure.

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

  local constants = getconstants(target)

  for index, value in pairs(constants) do
      print(index, value)
  end
  ```
</div>
