Skip to content

Commit 876a9ca

Browse files
beyondlimitsparamat
authored andcommitted
Beds: Fix input checking for "Force night skip"
1 parent 255031f commit 876a9ca

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

mods/beds/functions.lua

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,25 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
219219
if formname ~= "beds_form" then
220220
return
221221
end
222+
223+
-- Because "Force night skip" button is a button_exit, it will set fields.quit
224+
-- and lay_down call will change value of player_in_bed, so it must be taken
225+
-- earlier.
226+
local last_player_in_bed = player_in_bed
227+
222228
if fields.quit or fields.leave then
223229
lay_down(player, nil, nil, false)
224230
update_formspecs(false)
225231
end
226232

227233
if fields.force then
228-
update_formspecs(is_night_skip_enabled())
229-
if is_night_skip_enabled() then
234+
local is_majority = (#minetest.get_connected_players() / 2) < last_player_in_bed
235+
if is_majority and is_night_skip_enabled() then
236+
update_formspecs(true)
230237
beds.skip_night()
231238
beds.kick_players()
239+
else
240+
update_formspecs(false)
232241
end
233242
end
234243
end)

0 commit comments

Comments
 (0)