File tree 3 files changed +17
-1
lines changed
3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 53
53
function minetest .get_connected_players ()
54
54
local temp_table = {}
55
55
for index , value in pairs (player_list ) do
56
- table.insert (temp_table , value )
56
+ if value :is_player_connected () then
57
+ table.insert (temp_table , value )
58
+ end
57
59
end
58
60
return temp_table
59
61
end
Original file line number Diff line number Diff line change @@ -621,6 +621,16 @@ int ObjectRef::l_is_player(lua_State *L)
621
621
return 1 ;
622
622
}
623
623
624
+ // is_player_connected(self)
625
+ int ObjectRef::l_is_player_connected (lua_State *L)
626
+ {
627
+ NO_MAP_LOCK_REQUIRED;
628
+ ObjectRef *ref = checkobject (L, 1 );
629
+ Player *player = getplayer (ref);
630
+ lua_pushboolean (L, (player != NULL && player->peer_id != 0 ));
631
+ return 1 ;
632
+ }
633
+
624
634
// get_player_name(self)
625
635
int ObjectRef::l_get_player_name (lua_State *L)
626
636
{
@@ -1148,6 +1158,7 @@ const luaL_reg ObjectRef::methods[] = {
1148
1158
luamethod (ObjectRef, get_luaentity),
1149
1159
// Player-only
1150
1160
luamethod (ObjectRef, is_player),
1161
+ luamethod (ObjectRef, is_player_connected),
1151
1162
luamethod (ObjectRef, get_player_name),
1152
1163
luamethod (ObjectRef, get_look_dir),
1153
1164
luamethod (ObjectRef, get_look_pitch),
Original file line number Diff line number Diff line change @@ -158,6 +158,9 @@ class ObjectRef : public ModApiBase {
158
158
// is_player(self)
159
159
static int l_is_player (lua_State *L);
160
160
161
+ // is_player_connected(self)
162
+ static int l_is_player_connected (lua_State *L);
163
+
161
164
// get_player_name(self)
162
165
static int l_get_player_name (lua_State *L);
163
166
You can’t perform that action at this time.
0 commit comments