Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
86ef7147
Commit
86ef7147
authored
11 years ago
by
kwolekr
Browse files
Options
Downloads
Patches
Plain Diff
Fix issue #1009 (minetest.get_connected_players() returns non-existing players)
parent
a55c073c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
builtin/misc.lua
+3
-1
3 additions, 1 deletion
builtin/misc.lua
src/script/lua_api/l_object.cpp
+11
-0
11 additions, 0 deletions
src/script/lua_api/l_object.cpp
src/script/lua_api/l_object.h
+3
-0
3 additions, 0 deletions
src/script/lua_api/l_object.h
with
17 additions
and
1 deletion
builtin/misc.lua
+
3
−
1
View file @
86ef7147
...
...
@@ -53,7 +53,9 @@ end)
function
minetest
.
get_connected_players
()
local
temp_table
=
{}
for
index
,
value
in
pairs
(
player_list
)
do
table.insert
(
temp_table
,
value
)
if
value
:
is_player_connected
()
then
table.insert
(
temp_table
,
value
)
end
end
return
temp_table
end
...
...
This diff is collapsed.
Click to expand it.
src/script/lua_api/l_object.cpp
+
11
−
0
View file @
86ef7147
...
...
@@ -621,6 +621,16 @@ int ObjectRef::l_is_player(lua_State *L)
return
1
;
}
// is_player_connected(self)
int
ObjectRef
::
l_is_player_connected
(
lua_State
*
L
)
{
NO_MAP_LOCK_REQUIRED
;
ObjectRef
*
ref
=
checkobject
(
L
,
1
);
Player
*
player
=
getplayer
(
ref
);
lua_pushboolean
(
L
,
(
player
!=
NULL
&&
player
->
peer_id
!=
0
));
return
1
;
}
// get_player_name(self)
int
ObjectRef
::
l_get_player_name
(
lua_State
*
L
)
{
...
...
@@ -1148,6 +1158,7 @@ const luaL_reg ObjectRef::methods[] = {
luamethod
(
ObjectRef
,
get_luaentity
),
// Player-only
luamethod
(
ObjectRef
,
is_player
),
luamethod
(
ObjectRef
,
is_player_connected
),
luamethod
(
ObjectRef
,
get_player_name
),
luamethod
(
ObjectRef
,
get_look_dir
),
luamethod
(
ObjectRef
,
get_look_pitch
),
...
...
This diff is collapsed.
Click to expand it.
src/script/lua_api/l_object.h
+
3
−
0
View file @
86ef7147
...
...
@@ -158,6 +158,9 @@ class ObjectRef : public ModApiBase {
// is_player(self)
static
int
l_is_player
(
lua_State
*
L
);
// is_player_connected(self)
static
int
l_is_player_connected
(
lua_State
*
L
);
// get_player_name(self)
static
int
l_get_player_name
(
lua_State
*
L
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment