-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minetest.get_connected_players should not return nil #9490
Comments
'nil' seems suitable because no players are connected. What was the previous behaviour? Will it break mods if it has changed from {}? |
Yes, this has broken at least "mobs", "mineclone2" and "crafting" so far. Given that this function is in "misc" and not "environment" in the documentation, and there is no indication that this does not work at load time, then I would consider this a break in behaviour See the related discussion in #minetest-dev: http://irc.minetest.net/minetest-dev/2020-03-09#i_5649975 |
I would very much prefer it continues to return |
It's because the server (and so the environment/world) isn't initialised yet. If there are no players connected and the server isn't currently loading then |
Returning nil makes more sense in the C++ code. That part is also hidden inside the Also this issue is a duplicate of #9428. |
To the actual issue: I'm okay with making it return |
Ok, to be clear i have no objection to {}, obviously (to not break stuff). |
Because the number of players is NOT actually zero, There cannot be players at load time. Why any mod would query a list of players (or do anything server-related) when the server is not in a consistent state is completely baffling. This shouldn't even have to be documented, since it's common sense that these API functions might eventually fail. The fact that they even worked up till now is a fluke. The only thing that should happen at load time is to perform registrations, initialize variables, setup data structures, read settings and configuration, etc.
|
We are not permitting this, we are logging a deprecated warning rather than crashing mods. In a few releases we can then change the behaviour (I'm for a rule where removing something isn't a breaking change if there has been at least one release which has a deprecation warning) |
Okay, that's great news! The deprecation warning is in-line with the suggestion I made yesterday on the forums. I had no idea that was the resolution, since there was no mention of option for a deprecation warning in Wuzzy's original post, only restoring the original behavior. So that's why I was so concerned. Thanks for clarifying :) |
Oh, I forgot that the op didn't mention that |
Minetest version
Summary
If you all
minetest.get_connected_players()
during loadtime, it returnsnil
. This is a regression from 5.1.1.lua_api.txt
of 5.1.1 clearly states:Expected behavior
It returns
{}
on loadtime, since, in fact, no players are connected yet.The text was updated successfully, but these errors were encountered: