forked from minetest/minetest_game
Beds: Fix input checking for "Force night skip"
This commit is contained in:
parent
255031fc91
commit
876a9ca5d2
@ -219,16 +219,25 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||||||
if formname ~= "beds_form" then
|
if formname ~= "beds_form" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Because "Force night skip" button is a button_exit, it will set fields.quit
|
||||||
|
-- and lay_down call will change value of player_in_bed, so it must be taken
|
||||||
|
-- earlier.
|
||||||
|
local last_player_in_bed = player_in_bed
|
||||||
|
|
||||||
if fields.quit or fields.leave then
|
if fields.quit or fields.leave then
|
||||||
lay_down(player, nil, nil, false)
|
lay_down(player, nil, nil, false)
|
||||||
update_formspecs(false)
|
update_formspecs(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.force then
|
if fields.force then
|
||||||
update_formspecs(is_night_skip_enabled())
|
local is_majority = (#minetest.get_connected_players() / 2) < last_player_in_bed
|
||||||
if is_night_skip_enabled() then
|
if is_majority and is_night_skip_enabled() then
|
||||||
|
update_formspecs(true)
|
||||||
beds.skip_night()
|
beds.skip_night()
|
||||||
beds.kick_players()
|
beds.kick_players()
|
||||||
|
else
|
||||||
|
update_formspecs(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user