From 92385364e5434f6f77d192fdfb9b6745507ff73f Mon Sep 17 00:00:00 2001 From: kay27 Date: Thu, 30 Jul 2020 02:01:15 +0400 Subject: [PATCH] Fix beds #798 attempt 5 --- mods/ITEMS/mcl_beds/functions.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index de2b756620..d93b2b84d2 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -202,8 +202,13 @@ local function lay_down(player, pos, bed_pos, state, skip) return true end -local function update_formspecs(finished) - local ges = #minetest.get_connected_players() +local function update_formspecs(finished, players) + local ges + if players then + ges = #players + else + ges = #minetest.get_connected_players() + end local form_n = "size[6,5;true]" local all_in_bed = ges == player_in_bed local night_skip = is_night_skip_enabled() @@ -364,7 +369,14 @@ end) minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() lay_down(player, nil, nil, false, true) - if check_in_beds() then + players = minetest.get_connected_players() + for n, player in ipairs(players) do + if player:get_player_name() == name then + players[n] = nil + break + end + end + if check_in_beds(players) then minetest.after(5, function() if check_in_beds() then update_formspecs(is_night_skip_enabled()) @@ -372,7 +384,7 @@ minetest.register_on_leaveplayer(function(player) end end) end - update_formspecs(false) + update_formspecs(false, players) end) minetest.register_on_player_receive_fields(function(player, formname, fields)