mirror of
https://github.com/appgurueu/modlib.git
synced 2024-12-01 11:43:51 +01:00
Remove builtin global strictness
This commit is contained in:
parent
7c3ec02505
commit
98c702ee28
2
init.lua
2
init.lua
@ -1,3 +1,5 @@
|
|||||||
|
-- Silence builtin/strict.lua
|
||||||
|
setmetatable(_G, {})
|
||||||
-- Lua version check
|
-- Lua version check
|
||||||
if _VERSION then
|
if _VERSION then
|
||||||
if _VERSION < "Lua 5" then
|
if _VERSION < "Lua 5" then
|
||||||
|
8
mod.lua
8
mod.lua
@ -24,12 +24,8 @@ function create_namespace(namespace_name, parent_namespace)
|
|||||||
namespace_name = namespace_name or minetest.get_current_modname()
|
namespace_name = namespace_name or minetest.get_current_modname()
|
||||||
parent_namespace = parent_namespace or _G
|
parent_namespace = parent_namespace or _G
|
||||||
local namespace = setmetatable({}, {__index = parent_namespace})
|
local namespace = setmetatable({}, {__index = parent_namespace})
|
||||||
-- prevent MT's warning
|
-- should use rawset if MT's strictness wasn't disabled in init.lua
|
||||||
if parent_namespace == _G then
|
parent_namespace[namespace_name] = namespace
|
||||||
rawset(parent_namespace, namespace_name, namespace)
|
|
||||||
else
|
|
||||||
parent_namespace[namespace_name] = namespace
|
|
||||||
end
|
|
||||||
return namespace
|
return namespace
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user