[Snippet] Debug Calls

edited May 2016 in Tools

If your game mode is crashing or hanging inexplicably, you can use this function to find out what was the last call call

Warning, it spams a lot and makes your game slightly unplayable, use under your own risk.

function DebugCalls()
    if not GameRules.DebugCalls then
        print("Starting DebugCalls")
        GameRules.DebugCalls = true

        debug.sethook(function(...)
            local info = debug.getinfo(2)
            local src = tostring(info.short_src)
            local name = tostring(info.name)
            if name ~= "__index" then
                print("Call: ".. src .. " -- " .. name)
            end
        end, "c")
    else
        print("Stopped DebugCalls")
        GameRules.DebugCalls = false
        debug.sethook(nil, "c")
    end
end

Implemented as a chat-command in DotaCraft developer.lua, credits to BMD for finding debug.sethook and showing how to use it

The concept of Modding Community doesn't go well together with Competitive Business
My Project Page || My GitHub Profile ||