diff options
Diffstat (limited to 'script/utility.lua')
-rw-r--r-- | script/utility.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/script/utility.lua b/script/utility.lua index f62c7af3..8d377708 100644 --- a/script/utility.lua +++ b/script/utility.lua @@ -17,6 +17,7 @@ local mathRandom = math.random local ioOpen = io.open local utf8Len = utf8.len local getenv = os.getenv +local getupvalue = debug.getupvalue local mathHuge = math.huge local inf = 1 / 0 local nan = 0 / 0 @@ -684,4 +685,17 @@ function m.switch() return obj end +function m.getUpvalue(f, name) + for i = 1, 999 do + local uname, value = getupvalue(f, i) + if not uname then + break + end + if name == uname then + return value, true + end + end + return nil, false +end + return m |