mirror of
https://github.com/minetest/minetest_game.git
synced 2025-06-29 21:30:26 +02:00
Add option to disable bed's night skip - Solve second point of #512 by adding a setting, enable_bed_night_skip
, with default value of true
.
This commit is contained in:
@ -21,6 +21,14 @@ local function get_look_yaw(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local function is_night_skip_enabled()
|
||||
local enable_night_skip = minetest.setting_getbool("enable_bed_night_skip")
|
||||
if enable_night_skip == nil then
|
||||
enable_night_skip = true
|
||||
end
|
||||
return enable_night_skip
|
||||
end
|
||||
|
||||
local function check_in_beds(players)
|
||||
local in_bed = beds.player
|
||||
if not players then
|
||||
@ -56,7 +64,7 @@ local function lay_down(player, pos, bed_pos, state, skip)
|
||||
if skip then
|
||||
return
|
||||
end
|
||||
if p then
|
||||
if p then
|
||||
player:setpos(p)
|
||||
end
|
||||
|
||||
@ -100,8 +108,8 @@ local function update_formspecs(finished)
|
||||
"label[2.7,11; Good morning.]"
|
||||
else
|
||||
form_n = beds.formspec ..
|
||||
"label[2.2,11;"..tostring(player_in_bed).." of "..tostring(ges).." players are in bed]"
|
||||
if is_majority then
|
||||
"label[2.2,11;"..tostring(player_in_bed).." of "..tostring(ges).." players are in bed]"
|
||||
if is_majority and is_night_skip_enabled() then
|
||||
form_n = form_n ..
|
||||
"button_exit[2,8;4,0.75;force;Force night skip]"
|
||||
end
|
||||
@ -154,11 +162,13 @@ function beds.on_rightclick(pos, player)
|
||||
-- skip the night and let all players stand up
|
||||
if check_in_beds() then
|
||||
minetest.after(2, function()
|
||||
beds.skip_night()
|
||||
if not is_sp then
|
||||
update_formspecs(true)
|
||||
update_formspecs(is_night_skip_enabled())
|
||||
end
|
||||
if is_night_skip_enabled() then
|
||||
beds.skip_night()
|
||||
beds.kick_players()
|
||||
end
|
||||
beds.kick_players()
|
||||
end)
|
||||
end
|
||||
end
|
||||
@ -189,9 +199,11 @@ minetest.register_on_leaveplayer(function(player)
|
||||
beds.player[name] = nil
|
||||
if check_in_beds() then
|
||||
minetest.after(2, function()
|
||||
beds.skip_night()
|
||||
update_formspecs(true)
|
||||
beds.kick_players()
|
||||
update_formspecs(is_night_skip_enabled())
|
||||
if is_night_skip_enabled() then
|
||||
beds.skip_night()
|
||||
beds.kick_players()
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
@ -206,8 +218,10 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
end
|
||||
|
||||
if fields.force then
|
||||
beds.skip_night()
|
||||
update_formspecs(true)
|
||||
beds.kick_players()
|
||||
update_formspecs(is_night_skip_enabled())
|
||||
if is_night_skip_enabled() then
|
||||
beds.skip_night()
|
||||
beds.kick_players()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
Reference in New Issue
Block a user