From 0dcc4b251f4de4631d2211e1be3f65b8da15439d Mon Sep 17 00:00:00 2001 From: sapier Date: Sun, 23 Nov 2014 15:24:37 +0100 Subject: Fix console spaming by debug function on mod checking for global variable to exist. --- builtin/common/strict.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'builtin/common') 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 -- cgit v1.2.3