mirror of
https://github.com/appgurueu/modlib.git
synced 2025-02-16 16:22:30 +01:00
Unsilence builtin/strict.lua
This commit is contained in:
2
init.lua
2
init.lua
@ -1,5 +1,3 @@
|
||||
-- Silence builtin/strict.lua
|
||||
setmetatable(_G, {})
|
||||
-- Lua version check
|
||||
if _VERSION then
|
||||
if _VERSION < "Lua 5" then
|
||||
|
@ -687,7 +687,7 @@ function colorspec:to_number()
|
||||
return self.r * 0xFFFFFF + self.g * 0xFFFF + self.b * 0xFF + self.a
|
||||
end
|
||||
|
||||
colorspec_to_colorstring = _G.minetest.colorspec_to_colorstring or function(spec)
|
||||
colorspec_to_colorstring = rawget(_G, "minetest").colorspec_to_colorstring or function(spec)
|
||||
return colorspec.from_any(spec):to_string()
|
||||
end
|
||||
|
||||
|
13
mod.lua
13
mod.lua
@ -14,9 +14,14 @@ end
|
||||
function create_namespace(namespace_name, parent_namespace)
|
||||
namespace_name = namespace_name or minetest.get_current_modname()
|
||||
parent_namespace = parent_namespace or _G
|
||||
local namespace = setmetatable({}, {__index = parent_namespace})
|
||||
-- should use rawset if MT's strictness wasn't disabled in init.lua
|
||||
parent_namespace[namespace_name] = namespace
|
||||
local metatable = {__index = parent_namespace == _G and function(_, key) return rawget(_G, key) end or parent_namespace}
|
||||
local namespace = {}
|
||||
namespace = setmetatable(namespace, metatable)
|
||||
if parent_namespace == _G then
|
||||
rawset(parent_namespace, namespace_name, namespace)
|
||||
else
|
||||
parent_namespace[namespace_name] = namespace
|
||||
end
|
||||
return namespace
|
||||
end
|
||||
|
||||
@ -26,7 +31,7 @@ function extend(modname, file)
|
||||
file = modname
|
||||
modname = minetest.get_current_modname()
|
||||
end
|
||||
include_env(get_resource(modname, file .. ".lua"), _G[modname])
|
||||
include_env(get_resource(modname, file .. ".lua"), rawget(_G, modname))
|
||||
end
|
||||
|
||||
-- runs main.lua in table env
|
||||
|
Reference in New Issue
Block a user