summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_client.cpp
diff options
context:
space:
mode:
authorbigfoot547 <bigfoot547@users.noreply.github.com>2017-03-22 15:13:03 -0500
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-03-22 21:13:03 +0100
commit9efc5da0fb7d276deff55db6e4eb89d24ca72b5d (patch)
tree5f6c3d614d2f2780867c3407c7a94c0f26a29b41 /src/script/lua_api/l_client.cpp
parentc4b98deb616fbe204c503d678fb920baa33cbede (diff)
downloadminetest-9efc5da0fb7d276deff55db6e4eb89d24ca72b5d.tar.gz
minetest-9efc5da0fb7d276deff55db6e4eb89d24ca72b5d.tar.bz2
minetest-9efc5da0fb7d276deff55db6e4eb89d24ca72b5d.zip
[CSM] Add function to get player names in range (#5435)
* [CSM] Add function to get currently connected player names
Diffstat (limited to 'src/script/lua_api/l_client.cpp')
-rw-r--r--src/script/lua_api/l_client.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp
index 1673a62ce..52c7f6f30 100644
--- a/src/script/lua_api/l_client.cpp
+++ b/src/script/lua_api/l_client.cpp
@@ -69,6 +69,22 @@ int ModApiClient::l_display_chat_message(lua_State *L)
return 1;
}
+// get_player_names()
+int ModApiClient::l_get_player_names(lua_State *L)
+{
+ const std::list<std::string> &plist = getClient(L)->getConnectedPlayerNames();
+ lua_createtable(L, plist.size(), 0);
+ int newTable = lua_gettop(L);
+ int index = 1;
+ std::list<std::string>::const_iterator iter;
+ for (iter = plist.begin(); iter != plist.end(); iter++) {
+ lua_pushstring(L, (*iter).c_str());
+ lua_rawseti(L, newTable, index);
+ index++;
+ }
+ return 1;
+}
+
// show_formspec(formspec)
int ModApiClient::l_show_formspec(lua_State *L)
{
@@ -154,6 +170,7 @@ void ModApiClient::Initialize(lua_State *L, int top)
{
API_FCT(get_current_modname);
API_FCT(display_chat_message);
+ API_FCT(get_player_names);
API_FCT(set_last_run_mod);
API_FCT(get_last_run_mod);
API_FCT(show_formspec);