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
  • Parameter
  • Examples
  1. Debug

debug.getupvalues

Returns the upvalues of the specified function. nil will be returned if there is none.

function debug.getupvalues(func: (...any) -> (...any) | number): { any }

Parameter

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


Examples

local Var1 = false
local Var2 = "Hi"
local function DummyFunction()
    Var1 = true
    Var2..=", hello"
end

for UpvalIndex, UpvalValue in pairs(debug.getupvalues(DummyFunction)) do
    print(UpvalIndex, UpvalValue)
end

-- Output:
-- 1 false
-- 2 Hi
local Var1 = false
local function DummyFunction()
    print(Var1)
end

print(next(debug.getupvalues(DummyFunction))) -- Output: nil
print(debug.getupvalues(print)) -- Should error due to `print` being a C closure
Previousdebug.setconstantNextdebug.getupvalue

Last updated 2 months ago