og-pvpgn-server/lua/include/common.lua

26 lines
656 B
Lua
Raw Permalink Normal View History

--[[
Copyright (C) 2014 HarpyWar (harpywar@gmail.com)
This file is a part of the PvPGN Project http://pvpgn.pro
Licensed under the same terms as Lua itself.
]]--
2014-06-17 12:53:49 +04:00
-- Return the script path and line of the CURRENT function where it is executed
__FUNCTION__ = nil
2014-06-17 12:53:49 +04:00
-- Return the script path and line of the PARENT function where it is executed
__function__ = nil
setmetatable(_G, {__index =
function(t, k)
if k == '__FUNCTION__' then
local w = debug.getinfo(2, "S")
return w.short_src..":"..w.linedefined
2014-06-17 12:53:49 +04:00
elseif k == '__function__' then
local w = debug.getinfo(3, "S")
2014-06-17 12:53:49 +04:00
return w.short_src..":"..w.linedefined
end
end
})