diff options
author | sapier <Sapier at GMX dot net> | 2014-11-23 15:24:37 +0100 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-11-23 15:24:37 +0100 |
commit | 0dcc4b251f4de4631d2211e1be3f65b8da15439d (patch) | |
tree | c9087be0c134b73d57bffe3cfab2a7e16267325d /builtin/common | |
parent | 016448331061f87a63b8f9ef33671d81e8922ad1 (diff) | |
download | minetest-0dcc4b251f4de4631d2211e1be3f65b8da15439d.tar.gz minetest-0dcc4b251f4de4631d2211e1be3f65b8da15439d.tar.bz2 minetest-0dcc4b251f4de4631d2211e1be3f65b8da15439d.zip |
Fix console spaming by debug function on mod checking for global variable to exist.
Diffstat (limited to 'builtin/common')
-rw-r--r-- | builtin/common/strict.lua | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/builtin/common/strict.lua b/builtin/common/strict.lua index c4b181970..b6f4d6d2c 100644 --- a/builtin/common/strict.lua +++ b/builtin/common/strict.lua @@ -11,7 +11,7 @@ end local meta = {} local declared = {} - +local alreadywarned = {} function meta:__newindex(name, value) local info = debug.getinfo(2, "Sl") @@ -36,9 +36,10 @@ end function meta:__index(name) local info = debug.getinfo(2, "Sl") - if not declared[name] and info.what ~= "C" then + if not declared[name] and info.what ~= "C" and not alreadywarned[name] then warn(("Undeclared global variable %q accessed at %s:%s") :format(name, info.short_src, info.currentline)) + alreadywarned[name] = true end return rawget(self, name) end |