Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- getMethodBySignature(className: string OR number, methodName: string, signature: string): any
- -- Use for methods that share the same name. Note: Does not need the full signature, only needs the differences.
- ---Signatures are the value types of the function in the () in Dissect mono. EX: OpenDoor(front: bool, delay: single)
- -- EX: getInventoryMethod = getMethodBySignature("Inventory", ".ctor", "InventoryType, single, single")
- -- from: https://opencheattables.com/viewtopic.php?t=475
- function getMethodBySignature(className, methodName, signature)
- -- helper function to get mono methods from class string
- local function getClassMethods(className)
- local class = mono_findClass("", className)
- if class and class ~= 0 then
- return mono_class_enumMethods(class)
- end
- end
- local reformat = {[";"] = ",", [" "] = ""}
- if type(signature) ~= "string" then error("Signature must be a string") end
- local methods = type(className) == "number" and
- mono_class_enumMethods(className) or
- getClassMethods(className)
- if not methods then return end
- signature = signature:gsub(".", reformat)
- for _, v in ipairs(methods) do
- if v.name == methodName then
- local sign = mono_method_getSignature(v.method)
- if string.find(sign, signature) then
- return mono_compile_method(v.method)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment