HenryEx

getMethodBySignature

Aug 18th, 2026
4,562
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | Source Code | 0 0
  1. --- getMethodBySignature(className: string OR number, methodName: string, signature: string): any
  2. -- Use for methods that share the same name. Note: Does not need the full signature, only needs the differences.
  3. ---Signatures are the value types of the function in the () in Dissect mono. EX: OpenDoor(front: bool, delay: single)
  4. -- EX: getInventoryMethod = getMethodBySignature("Inventory", ".ctor", "InventoryType, single, single")
  5. -- from: https://opencheattables.com/viewtopic.php?t=475
  6.  
  7. function getMethodBySignature(className, methodName, signature)
  8.   -- helper function to get mono methods from class string
  9.   local function getClassMethods(className)
  10.     local class = mono_findClass("", className)
  11.  
  12.     if class and class ~= 0 then
  13.       return mono_class_enumMethods(class)
  14.     end
  15.   end
  16.  
  17.   local reformat = {[";"] = ",", [" "] = ""}
  18.  
  19.   if type(signature) ~= "string" then error("Signature must be a string") end
  20.  
  21.   local methods = type(className) == "number" and
  22.     mono_class_enumMethods(className) or
  23.     getClassMethods(className)
  24.   if not methods then return end
  25.  
  26.   signature = signature:gsub(".", reformat)
  27.   for _, v in ipairs(methods) do
  28.     if v.name == methodName then
  29.       local sign = mono_method_getSignature(v.method)
  30.      
  31.       if string.find(sign, signature) then
  32.         return mono_compile_method(v.method)
  33.       end
  34.     end
  35.   end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment