Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- @param class [Class type] in pd2. e.g WeaponTweakData PlayerManager
- @param class_name [String type] label to be used as identification in output. e.g "Class 1" "WeapTweak"
- @param serialize_vararg [Boolean type] that enables verbose output of arguments used when a method is called.
- @param bypass [Boolean type] that bypasses Lua metatable classes for use with anonymous classes. e.g Used with class = _G
- ]]
- function tagclass(class, class_name, serialize_vararg, bypass)
- class_name = class_name or tostring(class)
- log("Tagged " .. tostring(class) .. " as " .. tostring(class_name))
- if bypass then
- class = getmetatable(class)
- end
- if type(class) == "table" or bypass then
- for func_name,_ in pairs(class) do
- if type(class[func_name]) == "function" then
- -- Hooks:PreHook(class, tostring(func_name), tostring(Application:time()), function(...)
- local old_func = class[func_name]
- class[func_name] = function(...)
- local args = table.pack(...)
- local num_args = args.n
- local serial = ""
- if serialize_vararg then
- -- log("\t"..tostring(num_args-1).." total args!!!")
- for i=2, num_args, 1 do
- -- log("\t"..tostring(args[i]))
- if (i == num_args) then
- if type(args[i]) == "string" then
- serial = serial .. " \"" .. tostring(args[i]) .. "\""
- else
- serial = serial .. " " .. tostring(args[i])
- end
- else
- if type(args[i]) == "string" then
- serial = serial .. " \"" .. tostring(args[i]) .. "\" ,"
- else
- serial = serial .. " " .. tostring(args[i]) .. " ,"
- end
- end
- end
- -- outTree(args)
- else
- serial = " "
- end
- log("function " .. tostring(class_name) .. " : " .. tostring(func_name) .. " (" .. tostring(serial) .. " )")
- return old_func(...)
- end
- end
- end
- else
- log("CLASS is not a TABLE! Use BYPASS!")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement