Reset spawn position on bed destruction
authorDS <vorunbekannt75@web.de>
Sun, 26 Jan 2020 17:59:44 +0000 (18:59 +0100)
committerSmallJoker <SmallJoker@users.noreply.github.com>
Sun, 26 Jan 2020 17:59:44 +0000 (18:59 +0100)
mods/beds/api.lua
mods/beds/spawns.lua

index c545a201d584960b0c4e6dc2c2c97e2ac6345065..cab2def5536a6c34a8a135d67c190443369c053f 100644 (file)
@@ -17,6 +17,8 @@ local function destruct_bed(pos, n)
                reverse = not reverse
                minetest.remove_node(other)
                minetest.check_for_falling(other)
+               beds.remove_spawns_at(pos)
+               beds.remove_spawns_at(other)
        else
                reverse = not reverse
        end
index baee364df68c6d44a6821216e94c7b18726a2a49..1a2ce8100664f4c31bfc137274cda9c10f6dc254 100644 (file)
@@ -61,3 +61,12 @@ function beds.set_spawns()
        end
        beds.save_spawns()
 end
+
+function beds.remove_spawns_at(pos)
+       for name, p in pairs(beds.spawn) do
+               if vector.equals(vector.round(p), pos) then
+                       beds.spawn[name] = nil
+               end
+       end
+       beds.save_spawns()
+end