1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-22 23:10:17 +01:00

Beds: Replace hardcoded values of day interval with constants (#2990)

This commit is contained in:
ssdaniel24 2022-09-28 12:07:50 +03:00 committed by GitHub
parent 508a9070a0
commit 2e8ac46120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -49,6 +49,8 @@ Beds API
* `beds.read_spawns() ` Returns a table containing players respawn positions * `beds.read_spawns() ` Returns a table containing players respawn positions
* `beds.kick_players()` Forces all players to leave bed * `beds.kick_players()` Forces all players to leave bed
* `beds.skip_night()` Sets world time to morning and saves respawn position of all players currently sleeping * `beds.skip_night()` Sets world time to morning and saves respawn position of all players currently sleeping
* `beds.day_interval` Is a table with keys "start" and "finish". Allows you
to set the period of the day (timeofday format). Default: `{ start = 0.2, finish = 0.805 }`.
### Bed definition ### Bed definition

View File

@ -186,7 +186,7 @@ function beds.on_rightclick(pos, player)
local ppos = player:get_pos() local ppos = player:get_pos()
local tod = minetest.get_timeofday() local tod = minetest.get_timeofday()
if tod > 0.2 and tod < 0.805 then if tod > beds.day_interval.start and tod < beds.day_interval.finish then
if beds.player[name] then if beds.player[name] then
lay_down(player, nil, nil, false) lay_down(player, nil, nil, false)
end end

View File

@ -16,6 +16,11 @@ beds.formspec = "size[8,11;true]" ..
"bgcolor[#080808BB;true]" .. "bgcolor[#080808BB;true]" ..
"button_exit[2,10;4,0.75;leave;" .. esc(S("Leave Bed")) .. "]" "button_exit[2,10;4,0.75;leave;" .. esc(S("Leave Bed")) .. "]"
beds.day_interval = {
start = 0.2,
finish = 0.805,
}
local modpath = minetest.get_modpath("beds") local modpath = minetest.get_modpath("beds")
-- Load files -- Load files