From abd2681b505bd952d1ec471897b2a5a24ca31141 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Sun, 28 Jun 2020 12:05:39 -0600 Subject: [PATCH] ensuring that this mod's dieplayer callback is always called before the bones mod's dieplayer callback --- init.lua | 8 ++++++++ mod.conf | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) 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