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

debug.getstack

Returns all used values in the provided stack level.

function debug.getstack(level: number, index: number?): any | { any }

Parameters

  • level - The call stack.

  • index? - The position of the values inside the stack frame.


Examples

-- level 1
local Count = 0
local function RecursiveFunction() -- Entering a level deeper, meaning we can call using level 2 in this function
    Count += 1
    if Count > 6 then return end -- We'll stop at 6 to not retrieve useless information for our example
    local a = 29
    local b = true
    local c = "Example"
    a += 1
    b = false
    c..="s"
    print(debug.getstack(1, Count))
    RecursiveFunction()
end

RecursiveFunction()
-- Output:
-- 30
-- false
-- Examples
-- function: 0x...  <-- print function
-- function: 0x...  <-- getstack function
-- 1  <-- argument provided to getstack function
local function DummyFunction() return "Hello" end
local Var = 5
Var += 1

(function()
    print(debug.getstack(2)[1]()) -- Output: Hello
    print(debug.getstack(2)[2]) -- Output: 6
end)()
Previousdebug.setupvalueNextdebug.setstack

Last updated 2 months ago