Add MineCraft like sleeping player hud (#4011)

This adds a sleeping hud/actionbar that'll be displayed to players currently not sleeping.

Reviewed-on: MineClone2/MineClone2#4011
Reviewed-by: the-real-herowl <the-real-herowl@noreply.git.minetest.land>
Co-authored-by: chmodsayshello <chmodsayshello@hotmail.com>
Co-committed-by: chmodsayshello <chmodsayshello@hotmail.com>
This commit is contained in:
chmodsayshello 2023-11-18 21:21:17 +00:00 committed by the-real-herowl
parent 613ab897b2
commit 6ee2dbe70c
3 changed files with 13 additions and 2 deletions

View File

@ -383,6 +383,15 @@ function mcl_beds.on_rightclick(pos, player, is_top)
end end
if message then if message then
mcl_title.set(player, "actionbar", {text=message, color="white", stay=60}) mcl_title.set(player, "actionbar", {text=message, color="white", stay=60})
else -- someone just successfully entered a bed
local connected_players = minetest.get_connected_players()
local sleep_hud_message = S("@1/@2 players currently in bed.", player_in_bed, players_in_bed_setting() * #connected_players / 100)
for _, player in pairs(connected_players) do
if not mcl_beds.player[player:get_player_name()] then -- only send message to players not sleeping.
if mcl_title.params_get(player) then mcl_title.clear(player) end -- clear, old message is still being displayed
mcl_title.set(player, "actionbar", {text=sleep_hud_message, color="white", stay=60})
end
end
end end
else else
lay_down(player, nil, nil, false) lay_down(player, nil, nil, false)

View File

@ -46,4 +46,5 @@ send!=senden!
You are missing the 'shout' privilege! It's required in order to talk in chat...=Ihnen fehlt das 'shout' Privileg! Es wird benötigt, um im Chat reden zu können... You are missing the 'shout' privilege! It's required in order to talk in chat...=Ihnen fehlt das 'shout' Privileg! Es wird benötigt, um im Chat reden zu können...
You exceeded the maximum number of messages per 10 seconds!=Sie haben die maximale Anzahl an Chatnachrichten pro 10 Sekunden überschritten! You exceeded the maximum number of messages per 10 seconds!=Sie haben die maximale Anzahl an Chatnachrichten pro 10 Sekunden überschritten!
Hey! Would you guys mind sleeping?=Hey, würdet Ihr bitte zu Bett gehen? Hey! Would you guys mind sleeping?=Hey, würdet Ihr bitte zu Bett gehen?
Sorry, but you have to wait @1 seconds until you may use this button again!=Sie müssen leider noch @1 Sekunden warten, bevor sie diesen Knopf erneut benutzen können! Sorry, but you have to wait @1 seconds until you may use this button again!=Sie müssen leider noch @1 Sekunden warten, bevor sie diesen Knopf erneut benutzen können!
@1/@2 players currently in bed.=@1/@2 Spieler aktuell im Bett.

View File

@ -46,4 +46,5 @@ send!=
You are missing the 'shout' privilege! It's required in order to talk in chat...= You are missing the 'shout' privilege! It's required in order to talk in chat...=
You exceeded the maximum number of messages per 10 seconds!= You exceeded the maximum number of messages per 10 seconds!=
Hey! Would you guys mind sleeping?= Hey! Would you guys mind sleeping?=
Sorry, but you have to wait @1 seconds until you may use this button again!= Sorry, but you have to wait @1 seconds until you may use this button again!=
@1/@2 players currently in bed.=