1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-11-29 03:33:48 +00:00

compat stubs: fix warnings on death-reload

This commit is contained in:
fgenesis 2024-07-16 03:37:13 +02:00
parent 98c6b716d7
commit 9251278e46

View file

@ -3,6 +3,11 @@
----------------------------------------------------
local warnLog = (isDeveloperKeys() and errorLog) or debugLog
local STUBS = rawget(_G, ".._compat_util_stubs")
if not STUBS then
STUBS = {}
rawset(_G, ".._compat_util_stubs", STUBS)
end
-- generate function that warns when called and returns nil
local function warndummy(name)
@ -34,11 +39,12 @@ end
local function makestubs(tab, gen)
for name, param in pairs(tab) do
if rawget(_G, name) then
if not STUBS[name] and rawget(_G, name) then
errorLog("WARNING: oldfunctions.lua: function " .. name .. " already exists")
else
local f = gen(name, param)
rawset(_G, name, f)
STUBS[name] = f
end
end
end