No longer a way to check if player is online?
- 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?
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.
-
- 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?
minetest.get_connected_players() maybe?
- 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?
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.
Re: No longer a way to check if player is online?
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
local player_name = "steve"
local player = minetest.get_player_by_name(player_name)
if not player then print(player_name .. " isnt online") end
- 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?
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.
- rubenwardy
- Moderator
- Posts: 6978
- 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?
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
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
- 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?
it definitely did exist, it was the backbone of my old mod ocular networks' power system lolrubenwardy wrote: ↑Thu Jul 15, 2021 23:24I 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
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.
- rubenwardy
- Moderator
- Posts: 6978
- 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?
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
- 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?
Didn't the dev wiki count as 'documented'? cause that's the only way I'd have known of it.rubenwardy wrote: ↑Fri Jul 16, 2021 09:13OK, 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
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.
- rubenwardy
- Moderator
- Posts: 6978
- 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?
No, the dev wiki doesn't count as official documentation. It also should have never been documented in the dev wiki.
- Wuzzy
- Member
- Posts: 4803
- 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?
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
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
- 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?
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.
- 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?
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)
If urgend, you find me in Roblox (as CNXThomas)
- 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?
the only extant method of mass-deleting pages is a plugin called DeleteBatch that requires PHP editing of the wiki sourceWuzzy wrote: ↑Thu Jul 29, 2021 06:06Sadly, 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
Guidebook Lib, for in-game docs | Poly Decor, some cool blocks | Vision Lib, an all-purpose library.
Who is online
Users browsing this forum: No registered users and 11 guests