Qugurun

din_test

Jun 12th, 2021 (edited)
641
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function test (filename, lvl)
  2.     local debugInfo = debug.getinfo(lvl)
  3.    
  4.     if debugInfo ~= nil then
  5.         local name = debugInfo.source:match(".*\\([^.]+)") --> main
  6.        
  7.         if name ~= filename then
  8.         --if filename and name ~= filename then
  9.             if lvl > 3 then
  10.                 return test(filename, lvl + 2)
  11.             else
  12.                 return name, lvl
  13.             end
  14.         else
  15.             return name, lvl
  16.         end
  17.     else
  18.         return filename, nil
  19.     end
  20. end
  21.  
  22. print(test("main", 1)) --> main 1
RAW Paste Data