From: sapier Date: Sun, 23 Nov 2014 14:24:37 +0000 (+0100) Subject: Fix console spaming by debug function on mod checking for global variable to exist. X-Git-Tag: 0.4.11~143 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0dcc4b251f4de4631d2211e1be3f65b8da15439d;p=oweals%2Fminetest.git Fix console spaming by debug function on mod checking for global variable to exist. --- 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