1
0
Fork 0

Kick player out of bed when bed destroyed

This commit is contained in:
Wuzzy 2019-02-20 18:01:21 +01:00
parent 942b9468ff
commit f18b1bd52a
1 changed files with 14 additions and 0 deletions

View File

@ -22,6 +22,18 @@ local function destruct_bed(pos, n)
end end
end end
local function kick_player_after_destruct(pos)
for name, _ in pairs(mcl_beds.pos) do
if vector.equals(pos, mcl_beds.pos) then
local player = minetest.get_player_by_name(name)
if player and player:is_player() then
mcl_beds.kick_player(player)
break
end
end
end
end
local beddesc = "Beds allow you to sleep at night and make the time pass faster." local beddesc = "Beds allow you to sleep at night and make the time pass faster."
local beduse = "To use a bed, stand close to it and right-click the bed to sleep in it. Sleeping only works when the sun sets, at night or during a thunderstorm. The bed must also be clear of any danger." local beduse = "To use a bed, stand close to it and right-click the bed to sleep in it. Sleeping only works when the sun sets, at night or during a thunderstorm. The bed must also be clear of any danger."
if minetest.settings:get_bool("enable_bed_respawn") == false then if minetest.settings:get_bool("enable_bed_respawn") == false then
@ -125,6 +137,7 @@ function mcl_beds.register_bed(name, def)
on_destruct = function(pos) on_destruct = function(pos)
destruct_bed(pos, 1) destruct_bed(pos, 1)
kick_player_after_destruct(pos)
end, end,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
@ -199,6 +212,7 @@ function mcl_beds.register_bed(name, def)
on_rotate = false, on_rotate = false,
on_destruct = function(pos) on_destruct = function(pos)
destruct_bed(pos, 2) destruct_bed(pos, 2)
kick_player_after_destruct(pos)
end, end,
}) })