【发布时间】:2014-09-27 07:48:46
【问题描述】:
我试图弄清楚当我全局覆盖它时如何找到调用特定函数的脚本。例如:
rawset(_G, 'print',
function()
--check if xxx program is calling, then print a different way
end)
或
_G.print =
fucntion()
--check if xxx program is calling, then print a different way
end
我如何确定哪个脚本正在调用 print()? 我知道我应该使用 lua 的调试功能,但我不确定具体是什么。
【问题讨论】:
-
应该指出,您可能无法在此处实际执行您想要的操作,因为您可能没有想要检查调用函数的信息(如名称) .
-
Etan,所以我没有办法做到这一点吗?我尝试了 debug.getinfo,似乎我无法获取有关调用该函数的文件的信息。
-
您是否控制调用 print 的脚本的加载?如果你这样做了,你可以尝试改变它的环境。
标签: function debugging lua overriding global