Skip to content

Commit

Permalink
ensuring that this mod's dieplayer callback is always called before t…
Browse files Browse the repository at this point in the history
…he bones mod's dieplayer callback
  • Loading branch information
FaceDeer committed Jun 28, 2020
1 parent ca71e46 commit abd2681
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
3 changes: 2 additions & 1 deletion mod.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
name = death_compass
description = A compass that points to the last place you died
description = A compass that points to the last place you died
optional_depends = bones

0 comments on commit abd2681

Please sign in to comment.