aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShadowNinja <noreply@gmail.com>2013-03-29 23:28:13 -0400
committerPerttu Ahola <celeron55@gmail.com>2013-04-23 09:47:08 +0300
commit3d4d0cb5749a68436cccd08b7a135f9bb7527038 (patch)
tree78bc54a818cb7abdca87e1bde76ac6fc2ad9bfeb /src
parent9894167bbf516c40bf2b8577179ff8f13b8b54e2 (diff)
downloadminetest-3d4d0cb5749a68436cccd08b7a135f9bb7527038.tar.gz
minetest-3d4d0cb5749a68436cccd08b7a135f9bb7527038.tar.bz2
minetest-3d4d0cb5749a68436cccd08b7a135f9bb7527038.zip
Add option to not prepend "Server -!- " to messages sent with minetest.chat_send_player()
Diffstat (limited to 'src')
-rw-r--r--src/scriptapi.cpp7
-rw-r--r--src/server.cpp7
-rw-r--r--src/server.h2
3 files changed, 11 insertions, 5 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp
index 8d472e6b8..3b0c15f8a 100644
--- a/src/scriptapi.cpp
+++ b/src/scriptapi.cpp
@@ -754,15 +754,18 @@ static int l_chat_send_all(lua_State *L)
return 0;
}
-// chat_send_player(name, text)
+// chat_send_player(name, text, prepend)
static int l_chat_send_player(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
const char *text = luaL_checkstring(L, 2);
+ bool prepend = true;
+ if (lua_isboolean(L, 3))
+ prepend = lua_toboolean(L, 3);
// Get server from registry
Server *server = get_server(L);
// Send
- server->notifyPlayer(name, narrow_to_wide(text));
+ server->notifyPlayer(name, narrow_to_wide(text), prepend);
return 0;
}
diff --git a/src/server.cpp b/src/server.cpp
index dda2165c8..62c190036 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -4606,12 +4606,15 @@ void Server::saveConfig()
g_settings->updateConfigFile(m_path_config.c_str());
}
-void Server::notifyPlayer(const char *name, const std::wstring msg)
+void Server::notifyPlayer(const char *name, const std::wstring msg, const bool prepend = true)
{
Player *player = m_env->getPlayer(name);
if(!player)
return;
- SendChatMessage(player->peer_id, std::wstring(L"Server: -!- ")+msg);
+ if (prepend)
+ SendChatMessage(player->peer_id, std::wstring(L"Server -!- ")+msg);
+ else
+ SendChatMessage(player->peer_id, msg);
}
bool Server::showFormspec(const char *playername, const std::string &formspec, const std::string &formname)
diff --git a/src/server.h b/src/server.h
index 52606b0cb..b668ecae4 100644
--- a/src/server.h
+++ b/src/server.h
@@ -456,7 +456,7 @@ public:
}
// Envlock and conlock should be locked when calling this
- void notifyPlayer(const char *name, const std::wstring msg);
+ void notifyPlayer(const char *name, const std::wstring msg, const bool prepend);
void notifyPlayers(const std::wstring msg);
void spawnParticle(const char *playername,
v3f pos, v3f velocity, v3f acceleration,