Skip to content

Commit

Permalink
Bed bugfix: Remove "reverse" toggle in favor of swap_node/set_node co…
Browse files Browse the repository at this point in the history
…mbo (#2976)
  • Loading branch information
jeremyshannon committed Dec 24, 2023
1 parent ff755ee commit 43185f1
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions mods/beds/api.lua
@@ -1,6 +1,4 @@

local reverse = true

local function destruct_bed(pos, n)
local node = minetest.get_node(pos)
local other
Expand All @@ -12,15 +10,14 @@ local function destruct_bed(pos, n)
local dir = minetest.facedir_to_dir(node.param2)
other = vector.add(pos, dir)
end

if reverse then
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
local oname = minetest.get_node(other).name
if minetest.get_item_group(oname, "bed") ~= 0 then
-- Swap node leaves meta, but doesn't call destruct_bed again
minetest.swap_node(other, {name = "air"})
minetest.remove_node(other) -- Now clear the meta
minetest.check_for_falling(other)
beds.remove_spawns_at(pos)
beds.remove_spawns_at(other)
end
end

Expand Down

0 comments on commit 43185f1

Please sign in to comment.