mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Allow customizing chat message format (#8529)
This commit is contained in:
parent
cc610c74a7
commit
d1c27c7e80
10 changed files with 111 additions and 47 deletions
|
@ -168,3 +168,25 @@ void ScriptApiServer::on_shutdown()
|
|||
runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
|
||||
}
|
||||
|
||||
std::string ScriptApiServer::formatChatMessage(const std::string &name,
|
||||
const std::string &message)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
||||
// Push function onto stack
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "format_chat_message");
|
||||
|
||||
// Push arguments onto stack
|
||||
lua_pushstring(L, name.c_str());
|
||||
lua_pushstring(L, message.c_str());
|
||||
|
||||
// Actually call the function
|
||||
lua_call(L, 2, 1);
|
||||
|
||||
// Fetch return value
|
||||
std::string ret = lua_tostring(L, -1);
|
||||
lua_pop(L, 1);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -36,14 +36,18 @@ public:
|
|||
// Calls on_shutdown handlers
|
||||
void on_shutdown();
|
||||
|
||||
// Calls core.format_chat_message
|
||||
std::string formatChatMessage(const std::string &name,
|
||||
const std::string &message);
|
||||
|
||||
/* auth */
|
||||
bool getAuth(const std::string &playername,
|
||||
std::string *dst_password,
|
||||
std::set<std::string> *dst_privs);
|
||||
std::string *dst_password,
|
||||
std::set<std::string> *dst_privs);
|
||||
void createAuth(const std::string &playername,
|
||||
const std::string &password);
|
||||
const std::string &password);
|
||||
bool setPassword(const std::string &playername,
|
||||
const std::string &password);
|
||||
const std::string &password);
|
||||
private:
|
||||
void getAuthHandler();
|
||||
void readPrivileges(int index, std::set<std::string> &result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue