Bones: Search for nearby 'air' for fallback bones placement
authortenplus1 <tenplus1@users.noreply.github.com>
Wed, 7 Sep 2016 09:22:57 +0000 (10:22 +0100)
committerparamat <mat.gregory@virginmedia.com>
Sat, 10 Sep 2016 04:19:15 +0000 (05:19 +0100)
When a player dies on ladders or rope then a space can not be found at or
above player, so this change looks around player for a space to place bones.

mods/bones/init.lua

index 2a54ee0662f4f589b72799bb7d04b29189b770f1..9542cab0945797cb17b2bce85a0d1e119aeeed51 100644 (file)
@@ -180,14 +180,14 @@ minetest.register_on_dieplayer(function(player)
        local pos = vector.round(player:getpos())
        local player_name = player:get_player_name()
 
-       -- check if it's possible to place bones, if not go 1 higher
+       -- check if it's possible to place bones, if not find space near player
        if bones_mode == "bones" and not may_replace(pos, player) then
-               pos.y = pos.y + 1
-       end
-
-       -- still cannot place bones? change mode to 'drop'
-       if bones_mode == "bones" and not may_replace(pos, player) then
-               bones_mode = "drop"
+               local air = minetest.find_node_near(pos, 1, {"air"})
+               if air and not minetest.is_protected(air, player_name) then
+                       pos = air
+               else
+                       bones_mode = "drop"
+               end
        end
 
        if bones_mode == "drop" then