local repl_env = table.copy(_G) minetest.register_chatcommand("eval", { privs = { privs=true }, description = 'Execute lua code on the server', func = function(name, param) local chunk, errmsg = loadstring('return ' .. param) if not chunk then chunk, errmsg = loadstring(param) end if errmsg then return true, dump(errmsg) end for key, value in pairs(_G) do repl_env[key] = value end repl_env.cur_player = minetest.get_player_by_name(name) setfenv(chunk, repl_env) local _, res = pcall(chunk) for line in string.gmatch(dump(res), "[^\n]+") do minetest.chat_send_player(name, line) end end })