mirror of
https://github.com/minetest/minetest.git
synced 2024-11-14 03:33:44 +01:00
5e507c9829
This adds a chat console the server owner can use for administration or to talk with players. It runs in its own thread, which makes the user interface immune to the server's lag, behaving just like a client, except timeout. As it uses the same console code as the f10 console, things like nick completion or a scroll buffer basically come for free. The terminal itself is written in a general way so that adding a client version later on is just about implementing an interface. Fatal errors are printed after the console exists and the ncurses terminal buffer gets cleaned up with endwin(), so that the error still remains visible. The server owner can chose their username their entered text will have in chat and where players can send PMs to. Once the username is secured with a password to prevent anybody to take over the server, the owner can execute admin tasks over the console. This change includes a contribution by @kahrl who has improved ncurses library detection.
48 lines
1.3 KiB
Lua
48 lines
1.3 KiB
Lua
--
|
|
-- This file contains built-in stuff in Minetest implemented in Lua.
|
|
--
|
|
-- It is always loaded and executed after registration of the C API,
|
|
-- before loading and running any mods.
|
|
--
|
|
|
|
-- Initialize some very basic things
|
|
function core.debug(...) core.log(table.concat({...}, "\t")) end
|
|
if core.print then
|
|
local core_print = core.print
|
|
-- Override native print and use
|
|
-- terminal if that's turned on
|
|
function print(...)
|
|
core_print(table.concat({...}, "\t"))
|
|
end
|
|
core.print = nil -- don't pollute our namespace
|
|
end
|
|
math.randomseed(os.time())
|
|
os.setlocale("C", "numeric")
|
|
minetest = core
|
|
|
|
-- Load other files
|
|
local scriptdir = core.get_builtin_path()..DIR_DELIM
|
|
local gamepath = scriptdir.."game"..DIR_DELIM
|
|
local commonpath = scriptdir.."common"..DIR_DELIM
|
|
local asyncpath = scriptdir.."async"..DIR_DELIM
|
|
|
|
dofile(commonpath.."strict.lua")
|
|
dofile(commonpath.."serialize.lua")
|
|
dofile(commonpath.."misc_helpers.lua")
|
|
|
|
if INIT == "game" then
|
|
dofile(gamepath.."init.lua")
|
|
elseif INIT == "mainmenu" then
|
|
local mainmenuscript = core.setting_get("main_menu_script")
|
|
if mainmenuscript ~= nil and mainmenuscript ~= "" then
|
|
dofile(mainmenuscript)
|
|
else
|
|
dofile(core.get_mainmenu_path()..DIR_DELIM.."init.lua")
|
|
end
|
|
elseif INIT == "async" then
|
|
dofile(asyncpath.."init.lua")
|
|
else
|
|
error(("Unrecognized builtin initialization type %s!"):format(tostring(INIT)))
|
|
end
|
|
|