mirror of
https://github.com/pyrollo/display_modpack.git
synced 2024-12-12 07:53:15 +01:00
Replaced prints by minetest.log and code styling
This commit is contained in:
parent
fd4c8e6c68
commit
2b142e9dfe
@ -22,7 +22,8 @@
|
|||||||
function deprecated_group(deprecated_group, replacement_group)
|
function deprecated_group(deprecated_group, replacement_group)
|
||||||
for name, ndef in pairs(minetest.registered_nodes) do
|
for name, ndef in pairs(minetest.registered_nodes) do
|
||||||
if ndef.groups and ndef.groups[deprecated_group] then
|
if ndef.groups and ndef.groups[deprecated_group] then
|
||||||
minetest.log("warning", string.format('Node %s belongs to deprecated "%s" group which should be replaced with new "%s" group.',
|
minetest.log("warning", string.format(
|
||||||
|
'Node %s belongs to deprecated "%s" group which should be replaced with new "%s" group.',
|
||||||
name, deprecated_group, replacement_group))
|
name, deprecated_group, replacement_group))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -33,9 +34,10 @@ function deprecated_global_table(deprecated_global_name, replacement_global_name
|
|||||||
assert(type(replacement_global_name) == 'string', "replacement_global_name should be a string.")
|
assert(type(replacement_global_name) == 'string', "replacement_global_name should be a string.")
|
||||||
assert(deprecated_global_name ~= '', "deprecated_global_name should not be empty.")
|
assert(deprecated_global_name ~= '', "deprecated_global_name should not be empty.")
|
||||||
assert(replacement_global_name ~= '', "replacement_global_name should not be empty.")
|
assert(replacement_global_name ~= '', "replacement_global_name should not be empty.")
|
||||||
assert(rawget(_G, deprecated_global_name) == nil, "replacement global already exists.")
|
assert(rawget(_G, deprecated_global_name) == nil, "deprecated global does not exist.")
|
||||||
if _G[replacement_global_name] == nil then
|
if _G[replacement_global_name] == nil then
|
||||||
print('warn_deprecated_functions: Warning, replacement global "'..replacement_global_name..'" does not exists.')
|
minetest.log('warning', string.format(
|
||||||
|
'Replacement global "%s" does not exists.', replacement_global_name))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local meta = {
|
local meta = {
|
||||||
@ -44,15 +46,19 @@ function deprecated_global_table(deprecated_global_name, replacement_global_name
|
|||||||
__index = function(table, key)
|
__index = function(table, key)
|
||||||
local meta = getmetatable(table)
|
local meta = getmetatable(table)
|
||||||
local dbg = debug.getinfo(2, "lS")
|
local dbg = debug.getinfo(2, "lS")
|
||||||
minetest.log("warning", string.format('Warning: Accessing deprecated "%s" table, "%s" should be used instead (%s:%d).',
|
minetest.log("warning", string.format(
|
||||||
meta.deprecated, meta.replacement, (dbg.short_src or 'unknown'), (dbg.currentline or 0)))
|
'Accessing deprecated "%s" table, "%s" should be used instead (%s:%d).',
|
||||||
|
meta.deprecated, meta.replacement, (dbg.short_src or 'unknown'),
|
||||||
|
(dbg.currentline or 0)))
|
||||||
return _G[meta.replacement][key]
|
return _G[meta.replacement][key]
|
||||||
end,
|
end,
|
||||||
__newindex = function(table, key, value)
|
__newindex = function(table, key, value)
|
||||||
local meta = getmetatable(table)
|
local meta = getmetatable(table)
|
||||||
local dbg = debug.getinfo(2, "lS")
|
local dbg = debug.getinfo(2, "lS")
|
||||||
minetest.log("warning", string.format('Warning: Accessing deprecated "%s" table, "%s" should be used instead (%s:%d).',
|
minetest.log("warning", string.format(
|
||||||
meta.deprecated, meta.replacement, (dbg.short_src or 'unknown'), (dbg.currentline or 0)))
|
'Accessing deprecated "%s" table, "%s" should be used instead (%s:%d).',
|
||||||
|
meta.deprecated, meta.replacement, (dbg.short_src or 'unknown'),
|
||||||
|
(dbg.currentline or 0)))
|
||||||
_G[meta.replacement][key]=value
|
_G[meta.replacement][key]=value
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user