Skip to content
Snippets Groups Projects
Commit 0dcc4b25 authored by sapier's avatar sapier
Browse files

Fix console spaming by debug function on mod checking for global variable to exist.

parent 01644833
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment