Fix console spaming by debug function on mod checking for global variable to exist.
authorsapier <Sapier at GMX dot net>
Sun, 23 Nov 2014 14:24:37 +0000 (15:24 +0100)
committersapier <Sapier at GMX dot net>
Sun, 23 Nov 2014 14:24:37 +0000 (15:24 +0100)
builtin/common/strict.lua

index c4b18197083a3fa7fc01d08c950806ef6aa5dc95..b6f4d6d2c4a01b57fb4ff3e66f0e7c1e099a3974 100644 (file)
@@ -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