sunc docs
  • sUNC Introduction
  • Closures
    • hookfunction
    • hookmetamethod
    • newcclosure
    • iscclosure
    • islclosure
    • isexecutorclosure
    • clonefunction
    • getfunctionhash
  • Cryptography
    • crypt.base64encode
    • crypt.base64decode
  • Debug
    • debug.getconstants
    • debug.getconstant
    • debug.setconstant
    • debug.getupvalues
    • debug.getupvalue
    • debug.setupvalue
  • debug.getstack
  • debug.setstack
  • debug.getprotos
  • debug.getproto
  • Drawing
    • Drawing.new
      • Drawing Objects
    • cleardrawcache
    • getrenderproperty
    • setrenderproperty
    • isrenderobj
  • Environment
    • getgenv
    • getrenv
    • getgc
    • filtergc
  • Filesystem
    • appendfile
    • writefile
    • readfile
    • listfiles
    • isfile
    • delfile
    • loadfile
    • makefolder
    • isfolder
    • delfolder
    • getcustomasset
  • Instances
    • fireproximityprompt
    • fireclickdetector
    • firetouchinterest
    • getinstances
    • getnilinstances
    • cloneref
    • gethui
    • getcallbackvalue
    • compareinstances
  • Metatables
    • getrawmetatable
    • setrawmetatable
    • setreadonly
    • isreadonly
  • Miscellaneous
    • identifyexecutor
    • request
  • Reflection
    • gethiddenproperty
    • sethiddenproperty
    • setscriptable
    • checkcaller
    • setthreadidentity
    • getthreadidentity
  • Scripts
    • getscriptbytecode
    • getscripthash
    • getscriptclosure
    • getsenv
    • getscripts
    • getrunningscripts
    • getloadedmodules
    • getcallingscript
    • loadstring
  • Signals
    • getconnections
      • The Connection object
    • firesignal
    • replicatesignal
  • Websocket
    • WebSocket.connect
Powered by GitBook
On this page
  • Parameters
  • Examples
  1. Debug

debug.getconstant

Returns the constant at the specified index. If there is no constant at the specified index, nil will be returned instead.

function debug.getconstant(func: (...any) -> (...any) | number, index: number): number | string | boolean | nil

Parameters

  • func - The Lua function/level the constant would be obtained from.

  • index - Position of the wanted constant.


Examples

local function DummyFunction()
    local DummyString = "foo bar"
    string.split(DummyString, " ")
end

local Result = debug.getconstant(DummyFunction, 2)
print(Result) -- Output: string

-- Optimization Level: 1, Debug Level: 1
local function DummyFunction()
    local DummyString = "foo bar"
    string.split(DummyString, " ")
end

local Result = debug.getconstant(DummyFunction, 3)
print(Result) -- Output: nil

-- Optimization Level: 1, Debug Level: 1
print(debug.getconstant(print)) -- Should error due to being a C closure
Previousdebug.getconstantsNextdebug.setconstant

Last updated 2 months ago