Remove extra print() calls and copy Luacontroller's print behavior (#127)

This commit is contained in:
1F616EMO~nya
2024-07-03 13:34:18 +08:00
committed by GitHub
parent 71fe60014f
commit 5919f432ae
4 changed files with 13 additions and 8 deletions

View File

@ -229,11 +229,13 @@ end
-------------------------
local function safe_print(param)
local string_meta = getmetatable("")
local sandbox = string_meta.__index
string_meta.__index = string -- Leave string sandbox temporarily
print(dump(param))
string_meta.__index = sandbox -- Restore string sandbox
if (minetest.settings:get("pipeworks_lua_tube_print_behavior") or "log") == "log" then
local string_meta = getmetatable("")
local sandbox = string_meta.__index
string_meta.__index = string -- Leave string sandbox temporarily
minetest.log("action", string.format("[pipeworks.tubes.lua] print(%s)", dump(param)))
string_meta.__index = sandbox -- Restore string sandbox
end
end
local function safe_date()
@ -603,7 +605,7 @@ local function save_memory(pos, meta, mem)
meta:set_string("lc_memory", memstring)
meta:mark_as_private("lc_memory")
else
print("Error: lua_tube memory overflow. "..memsize_max.." bytes available, "
minetest.log("info", "lua_tube memory overflow. "..memsize_max.." bytes available, "
..#memstring.." required. Controller overheats.")
burn_controller(pos)
end