place_node crashes the game because of nil player, so add nil checks

* Fix for runtime error in callback `item_OnPlace()` due nill player/placer
* This is for forward preparation on minetest 5.X with backguard compatibility
* related to #39
* related to https://codeberg.org/minenux/minetest-game-adventuretest/issues/39
* related to https://github.com/Bremaweb/adventuretest/issues/39
* update NOTES.md with related fixed about MT 5.X migration
master
mckaygerhard 2023-01-13 08:27:48 -04:00
parent fceb855f2a
commit f1ff77133a
4 changed files with 8 additions and 2 deletions

View File

@ -3,6 +3,7 @@
### migration to mt 5.0/5.2
There are the issues Tignasse Verte mentionned: Adding `placer` in `register_functions.lua`
(related commit for minenux are commit a996d5ac709446322d6c6261c21e5f0752a6aeeb )
and replacing the two occourances of `nodeupdate` with `minetest.check_for_falling`.
Other changes are necessary because I changed (and had to change) quite a lot

View File

@ -98,7 +98,7 @@ minetest.register_on_dignode(adventuretest_dignode)
local function adventuretest_placenode(pos, node, placer)
hunger.handle_node_actions(pos,node,placer)
if placer:is_player() then
if placer and placer:is_player() then
local name = placer:get_player_name()
pd.increment(name,STAT_PLACED,1)

View File

@ -144,6 +144,7 @@ if minetest.setting_getbool("creative_mode") then
})
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
minetest.log("warning","[creative] maybe missing check for player here?")
return true
end)

View File

@ -2,8 +2,9 @@ local hb = {}
local scale = tonumber(core.setting_get("hud_scaling")) or 1
local function update_wheel(player)
local name = player:get_player_name()
if not player or not name then
if not player or not name or not player:is_player() then
return
end
@ -169,6 +170,9 @@ minetest.register_on_joinplayer(function(player)
end)
local function update_wrapper(a, b, player)
if not player or not player:is_player() then
return
end
local name = player:get_player_name()
if not name then
return