You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
That can be fixed by checking if the player is online via minetest.get_player_by_name() or similar, but that doesn't work for code inside an on_leaveplayer() callback, because player_api's on_leaveplayer() is called first (player_api is a dependency):
That also can be fixed, by just not running any player_api functions in an on_leaveplayer(), but in some cases you might have an on_leaveplayer() which calls a function (will name it test_func for later reference) from some other mod's API that's used on players at times other than a player exit, and calls a few player_api functions.
Given the above, the only ways I can think of to avoid a crash is to pcall(), insert your on_leaveplayer() callback to index 1, or when in an on_leaveplayer() callback, pass a bool to test_func which prevents use of player_api functions.
None of those feel like a good solution. I'd prefer to have access to something like player_api._players, or simply have the function return a failure value instead of triggering a crash
The text was updated successfully, but these errors were encountered:
Would it solve your problem if player_api registered its on_leaveplayer callback within minetest.register_on_mods_loaded? That would put move it to the end of the table, effectively calling it after all other mods.
Would it solve your problem if player_api registered its on_leaveplayer callback within minetest.register_on_mods_loaded? That would put move it to the end of the table, effectively calling it after all other mods.
Yeah. It wouldn't solve every possible issue but it fixes mine and is a step in a good direction IMO
The function
get_player_data()
is used for multiple API functions. But it asserts the value of a local table.minetest_game/mods/player_api/api.lua
Lines 51 to 58 in 9e77e00
That can be fixed by checking if the player is online via
minetest.get_player_by_name()
or similar, but that doesn't work for code inside anon_leaveplayer()
callback, because player_api'son_leaveplayer()
is called first (player_api is a dependency):minetest_game/mods/player_api/api.lua
Lines 165 to 169 in 9e77e00
That also can be fixed, by just not running any player_api functions in an
on_leaveplayer()
, but in some cases you might have anon_leaveplayer()
which calls a function (will name ittest_func
for later reference) from some other mod's API that's used on players at times other than a player exit, and calls a few player_api functions.Given the above, the only ways I can think of to avoid a crash is to
pcall()
, insert youron_leaveplayer()
callback to index 1, or when in anon_leaveplayer()
callback, pass a bool totest_func
which prevents use ofplayer_api
functions.None of those feel like a good solution. I'd prefer to have access to something like
player_api._players
, or simply have the function return a failure value instead of triggering a crashThe text was updated successfully, but these errors were encountered: