diff --git a/init.lua b/init.lua index 2505398..ae9951a 100644 --- a/init.lua +++ b/init.lua @@ -309,6 +309,14 @@ end) -- Called when a player dies -- `reason`: a PlayerHPChangeReason table, see register_on_player_hpchange +-- Using the regular minetest.register_on_dieplayer causes the new callback to be inserted *after* +-- the on_dieplayer used by the bones mod, which means the bones mod clears the player inventory before +-- we get to this and we can't tell if there was a death compass in it. +-- We must therefore rearrange the callback table to move this mod's callback to the front +-- to ensure it always goes first. +local death_compass_dieplayer_callback = table.remove(minetest.registered_on_dieplayers) +table.insert(minetest.registered_on_dieplayers, 1, death_compass_dieplayer_callback) + minetest.register_on_respawnplayer(function(player) local player_name = player:get_player_name() local compasses = player_death_location[player_name] diff --git a/mod.conf b/mod.conf index e6246bd..96223c3 100644 --- a/mod.conf +++ b/mod.conf @@ -1,2 +1,3 @@ name = death_compass -description = A compass that points to the last place you died \ No newline at end of file +description = A compass that points to the last place you died +optional_depends = bones \ No newline at end of file