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
Address set_player_privs
footgun
#14297
Conversation
builtin/game/auth.lua
Outdated
for priv, value in pairs(privileges) do | ||
-- Warnings for improper API usage | ||
if value == false then | ||
core.log('warning', "`false` value in `privs`, this is almost certainly a bug, ".. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably be core.log("deprecated"
also I would leave off the "granting a privilege rather than revoking it"
part
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went with grorp's suggestion.
builtin/game/auth.lua
Outdated
for priv, value in pairs(privileges) do | ||
-- Warnings for improper API usage | ||
if value == false then | ||
core.log('warning', "`false` value in `privs`, this is almost certainly a bug, ".. |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
d5099b6
to
dbf960a
Compare
By the way, it looks like |
Looks more like an internal engine helper to me. Please don't document it.
The C code hardcodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise
Co-authored-by: grorp <gregor.parzefall@posteo.de>
Straightforward PR to get rid of the
set_player_privs
footgun. This effectively does three things:privs
are a set,set_player_privs
replaces the privs (unlikeset_properties
for example, which just changes properties).false
values (modder probably meant to revoke), add warning for non-true
values (code smell).change_player_privs
convenience wrapper so modders have a function they can use to grant/revoke privs without having to callget_player_privs
/set_player_privs
themselves. I think granting / revoking privileges is probably the most common use case.How to test
minetest.set_player_privs("singleplayer", {interact = "maybe"})
should warn about a non-true
value.minetest.set_player_privs("singleplayer", {interact = false})
should warn about granting a privilege rather than revoking it.minetest.change_player_privs("singleplayer", {interact = 42})
should warn.minetest.change_player_privs("singleplayer", {fast = true, fly = false})
should grantfast
and revokefly
.