mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 15:23:48 +01:00
Make logfiles Minetest-independent
This commit is contained in:
parent
f516cc6bb8
commit
1ed07d6015
2
init.lua
2
init.lua
@ -78,7 +78,7 @@ end
|
||||
local load_module, get_resource, loadfile_exports
|
||||
modlib = setmetatable({
|
||||
-- TODO bump on release
|
||||
version = 63,
|
||||
version = 64,
|
||||
modname = minetest and minetest.get_current_modname(),
|
||||
dir_delim = rawget(_G, "DIR_DELIM") or "/",
|
||||
_RG = setmetatable({}, {
|
||||
|
@ -2,11 +2,11 @@ lua_log_file = {}
|
||||
local files = {}
|
||||
local metatable = {__index = lua_log_file}
|
||||
|
||||
-- TODO register on shutdown
|
||||
|
||||
function lua_log_file.new(file_path, root)
|
||||
local self = setmetatable({file_path = assert(file_path), root = root}, metatable)
|
||||
files[self] = true
|
||||
if minetest then
|
||||
files[self] = true
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
@ -53,11 +53,13 @@ function lua_log_file:close()
|
||||
files[self] = nil
|
||||
end
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
for self in pairs(files) do
|
||||
self.file:close()
|
||||
end
|
||||
end)
|
||||
if minetest then
|
||||
minetest.register_on_shutdown(function()
|
||||
for self in pairs(files) do
|
||||
self.file:close()
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- TODO use shorthand notations
|
||||
function lua_log_file:dump(value)
|
||||
|
Loading…
Reference in New Issue
Block a user