No longer a way to check if player is online?

Post Reply
User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

No longer a way to check if player is online?

by PolySaken » Post

player:is_player_connected() doesn't seem to exist any more, and I can't find any alternatives in lua_api.txt. Is it still possible to determine whether a player is online? If so, how?
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

twoelk
Member
Posts: 1482
Joined: Fri Apr 19, 2013 16:19
GitHub: twoelk
IRC: twoelk
In-game: twoelk
Location: northern Germany

Re: No longer a way to check if player is online?

by twoelk » Post

minetest.get_connected_players() maybe?

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: No longer a way to check if player is online?

by PolySaken » Post

twoelk wrote:
Thu Jul 15, 2021 09:20
minetest.get_connected_players() maybe?
Oh that seems to work, although it seems very hacky just to check if one particular player is online
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
TenPlus1
Member
Posts: 3700
Joined: Mon Jul 29, 2013 13:38
In-game: TenPlus1
Contact:

Re: No longer a way to check if player is online?

by TenPlus1 » Post

This is how I check if a player is online:

local player_name = "steve"
local player = minetest.get_player_by_name(player_name)
if not player then print(player_name .. " isnt online") end

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: No longer a way to check if player is online?

by PolySaken » Post

I guess i'll have to use one of these hacky methods. any idea why the original method was removed?
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: No longer a way to check if player is online?

by rubenwardy » Post

I don't recall is_player_connected ever existing, maybe it was in an early 0.4 version

The correct way to do this is to use minetest.get_player_by_name(name). This isn't hacky but is a well defined part of the API
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: No longer a way to check if player is online?

by PolySaken » Post

rubenwardy wrote:
Thu Jul 15, 2021 23:24
I don't recall is_player_connected ever existing, maybe it was in an early 0.4 version

The correct way to do this is to use minetest.get_player_by_name(name). This isn't hacky but is a well defined part of the API
it definitely did exist, it was the backbone of my old mod ocular networks' power system lol
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: No longer a way to check if player is online?

by rubenwardy » Post

PolySaken wrote:
Fri Jul 16, 2021 02:27
it definitely did exist, it was the backbone of my old mod ocular networks' power system lol
OK, searching the commit history, is_player_connected() was added in 2013 (0.4.7) but never documented. You shouldn't use undocumented functions as they can be removed or changed without warning

If you have a object, you can see if it is expired (unloaded, removed, or the player left) by checking whether object:get_pos() is nil. This will have the exact same behaviour as is_player_connected() did, but I don't think it's a nice way to to it. Using get_player_by_name(name) method is the better way to consistently check as it works without a player object
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: No longer a way to check if player is online?

by PolySaken » Post

rubenwardy wrote:
Fri Jul 16, 2021 09:13
PolySaken wrote:
Fri Jul 16, 2021 02:27
it definitely did exist, it was the backbone of my old mod ocular networks' power system lol
OK, searching the commit history, is_player_connected() was added in 2013 (0.4.7) but never documented. You shouldn't use undocumented functions as they can be removed or changed without warning

If you have a object, you can see if it is expired (unloaded, removed, or the player left) by checking whether object:get_pos() is nil. This will have the exact same behaviour as is_player_connected() did, but I don't think it's a nice way to to it. Using get_player_by_name(name) method is the better way to consistently check as it works without a player object
Didn't the dev wiki count as 'documented'? cause that's the only way I'd have known of it.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
rubenwardy
Moderator
Posts: 6969
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: No longer a way to check if player is online?

by rubenwardy » Post

PolySaken wrote:
Fri Jul 16, 2021 11:04
Didn't the dev wiki count as 'documented'? cause that's the only way I'd have known of it.
No, the dev wiki doesn't count as official documentation. It also should have never been documented in the dev wiki.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Wuzzy
Member
Posts: 4781
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: No longer a way to check if player is online?

by Wuzzy » Post

Sadly, I still have not found a way to mass-delete pages on MediaWiki which is why those pages about the Lua API are horribly outdated. The Dev Wiki is not only not official, it is, when it comes to the Lua API, also outright misleading.
Because I am definitely not manually deleting each offending page. Plus, I don't think I have the rights for that anyway.

Is there at least a way to auto-delete each MediaWiki page within a certain category? Because every offending page is part of a certain category.

Oh, if you say "Write a bot." I'm not going to do it. Way too risky it'll go horribly wrong.

I believe there are plugins for that, I guess, but those need to be installed by the admin first. :-(

BTW: The ONLY official Lua API documentation is the file "doc/lua_api.txt" in your Minetest installation.

Edit: I've now added a red warning on the main page of the Dev Wiki. Still not the real solution, but I hope it will be seen.

Edit 2: If any admin is reading this, I've made a list of what needs to be done to clean up the mess: https://dev.minetest.net/MinetestWiki:L ... on_Cleanup

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: No longer a way to check if player is online?

by PolySaken » Post

I know the wiki is no longer official, but i was under the impression that it used to be.
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

User avatar
Festus1965
Member
Posts: 4181
Joined: Sun Jan 03, 2016 11:58
GitHub: Festus1965
In-game: Festus1965 Thomas Thailand Explorer
Location: Thailand ChiangMai
Contact:

Re: No longer a way to check if player is online?

by Festus1965 » Post

PolySaken wrote:
Thu Jul 29, 2021 07:19
I know the wiki is no longer official, but i was under the impression that it used to be.
the basic problem is not official, then more if not actual or accurate.
Human has no future (climate change)
If urgend, you find me in Roblox (as CNXThomas)

User avatar
PolySaken
Member
Posts: 817
Joined: Thu Nov 09, 2017 05:18
GitHub: PolySaken-I-Am
In-game: PolySaken
Location: Wānaka, Aotearoa
Contact:

Re: No longer a way to check if player is online?

by PolySaken » Post

Wuzzy wrote:
Thu Jul 29, 2021 06:06
Sadly, I still have not found a way to mass-delete pages on MediaWiki which is why those pages about the Lua API are horribly outdated. The Dev Wiki is not only not official, it is, when it comes to the Lua API, also outright misleading.
Because I am definitely not manually deleting each offending page. Plus, I don't think I have the rights for that anyway.

Is there at least a way to auto-delete each MediaWiki page within a certain category? Because every offending page is part of a certain category.

Oh, if you say "Write a bot." I'm not going to do it. Way too risky it'll go horribly wrong.

I believe there are plugins for that, I guess, but those need to be installed by the admin first. :-(

BTW: The ONLY official Lua API documentation is the file "doc/lua_api.txt" in your Minetest installation.

Edit: I've now added a red warning on the main page of the Dev Wiki. Still not the real solution, but I hope it will be seen.

Edit 2: If any admin is reading this, I've made a list of what needs to be done to clean up the mess: https://dev.minetest.net/MinetestWiki:L ... on_Cleanup
the only extant method of mass-deleting pages is a plugin called DeleteBatch that requires PHP editing of the wiki source
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests