From 6ee2dbe70c2f082421dafafc368a243c3e04b849 Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Sat, 18 Nov 2023 21:21:17 +0000 Subject: [PATCH] Add MineCraft like sleeping player hud (#4011) This adds a sleeping hud/actionbar that'll be displayed to players currently not sleeping. Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/4011 Reviewed-by: the-real-herowl Co-authored-by: chmodsayshello Co-committed-by: chmodsayshello --- mods/ITEMS/mcl_beds/functions.lua | 9 +++++++++ mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr | 3 ++- mods/ITEMS/mcl_beds/locale/template.txt | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index fdb4f8f41..6c59fff04 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -383,6 +383,15 @@ function mcl_beds.on_rightclick(pos, player, is_top) end if message then 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 else lay_down(player, nil, nil, false) diff --git a/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr b/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr index 97867b44b..6771596a5 100644 --- a/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr +++ b/mods/ITEMS/mcl_beds/locale/mcl_beds.de.tr @@ -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 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? -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! \ No newline at end of file +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. \ No newline at end of file diff --git a/mods/ITEMS/mcl_beds/locale/template.txt b/mods/ITEMS/mcl_beds/locale/template.txt index 42e59509e..e604299e0 100644 --- a/mods/ITEMS/mcl_beds/locale/template.txt +++ b/mods/ITEMS/mcl_beds/locale/template.txt @@ -46,4 +46,5 @@ send!= 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!= Hey! Would you guys mind sleeping?= -Sorry, but you have to wait @1 seconds until you may use this button again!= \ No newline at end of file +Sorry, but you have to wait @1 seconds until you may use this button again!= +@1/@2 players currently in bed.= \ No newline at end of file