jail.lua:49: bad argument #1 to 'get_player_privs' (string expected, got userdata) #3279

Open
opened 2022-12-20 23:36:05 +00:00 by AliasAlreadyTaken · 1 comment

This happened on the testserver.

2022-12-20 04:54:34: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '' in callback on_joinplayer(): ...netest_test/bin/../mods/yl_commons/chatcommands/jail.lua:49: bad argument #1 to 'get_player_privs' (string expected, got userdata)
2022-12-20 04:54:34: ERROR[Main]: stack traceback:
2022-12-20 04:54:34: ERROR[Main]: 	[C]: in function 'get_player_privs'
2022-12-20 04:54:34: ERROR[Main]: 	...netest_test/bin/../mods/yl_commons/chatcommands/jail.lua:49: in function 'jail'
2022-12-20 04:54:34: ERROR[Main]: 	...netest_test/bin/../mods/yl_commons/chatcommands/jail.lua:173: in function 'func'
2022-12-20 04:54:34: ERROR[Main]: 	...inetest_test/bin/../builtin/profiler/instrumentation.lua:107: in function <...inetest_test/bin/../builtin/profiler/instrumentation.lua:100>
2022-12-20 04:54:34: ERROR[Main]: 	.../mt/5.6.1/Minetest_test/bin/../builtin/game/register.lua:431: in function <.../mt/5.6.1/Minetest_test/bin/../builtin/game/register.lua:417>

This is line 49:

function yl_commons.jail(target)
    -- Will teleport the player into the closed jail cell
    -- grant them invincibility, take their other privs off and
    -- store them in a table. Will also move the jailbird to the jail channel.
    -- teleport to jail cell
    move_to_jail(target)

    -- save privs
    local privstring = minetest.privs_to_string(minetest.get_player_privs(target)) <<<<
This happened on the testserver. ``` 2022-12-20 04:54:34: ERROR[Main]: ServerError: AsyncErr: Lua: Runtime error from mod '' in callback on_joinplayer(): ...netest_test/bin/../mods/yl_commons/chatcommands/jail.lua:49: bad argument #1 to 'get_player_privs' (string expected, got userdata) 2022-12-20 04:54:34: ERROR[Main]: stack traceback: 2022-12-20 04:54:34: ERROR[Main]: [C]: in function 'get_player_privs' 2022-12-20 04:54:34: ERROR[Main]: ...netest_test/bin/../mods/yl_commons/chatcommands/jail.lua:49: in function 'jail' 2022-12-20 04:54:34: ERROR[Main]: ...netest_test/bin/../mods/yl_commons/chatcommands/jail.lua:173: in function 'func' 2022-12-20 04:54:34: ERROR[Main]: ...inetest_test/bin/../builtin/profiler/instrumentation.lua:107: in function <...inetest_test/bin/../builtin/profiler/instrumentation.lua:100> 2022-12-20 04:54:34: ERROR[Main]: .../mt/5.6.1/Minetest_test/bin/../builtin/game/register.lua:431: in function <.../mt/5.6.1/Minetest_test/bin/../builtin/game/register.lua:417> ``` This is line 49: ``` function yl_commons.jail(target) -- Will teleport the player into the closed jail cell -- grant them invincibility, take their other privs off and -- store them in a table. Will also move the jailbird to the jail channel. -- teleport to jail cell move_to_jail(target) -- save privs local privstring = minetest.privs_to_string(minetest.get_player_privs(target)) <<<< ```
AliasAlreadyTaken added the
1. kind/bug
label 2022-12-21 00:46:41 +00:00
Member

local privstring = minetest.privs_to_string(minetest.get_player_privs(target))

get_player_privs, like a lot of things, requires a name as the argument, and not a player object.

that issue in the API has bugged me for ages, maybe i'll fix it. anything that can take a player name as an argument should also accept a player object, and most things that accept a player object ought to also accept a name.

> local privstring = minetest.privs_to_string(minetest.get_player_privs(target)) `get_player_privs`, like a lot of things, requires a *name* as the argument, and not a player object. that issue in the API has bugged me for ages, maybe i'll fix it. anything that can take a player name as an argument should also accept a player object, and most things that accept a player object ought to also accept a name.
flux added the
2. prio/elevated
label 2022-12-21 05:53:52 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: your-land/bugtracker#3279
No description provided.