From 5e06b35e79003e6ae1c3253ec292918ad443ca84 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sun, 2 Jul 2017 18:44:24 +0200 Subject: [PATCH] Add hb.get_hudbar_identifiers() --- API.md | 5 ++++- init.lua | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/API.md b/API.md index 312be99..a53344c 100644 --- a/API.md +++ b/API.md @@ -170,7 +170,7 @@ Makes a previously hidden HUD bar visible again to a player. ## Reading HUD bar information -It is also possible to read information about an active HUD bar. +It is also possible to read information about existing HUD bars. ### `hb.get_hudbar_state(player, identifier)` Returns the current state of the active player's HUD bar. @@ -191,3 +191,6 @@ hold by the table is only true for the moment you called this function. The fiel * `text`: The text shown on the HUD bar. This fiels is meaningless if the HUD bar is currently hidden. If the player does not exist, returns `nil` instead. + +### `hb.get_hudbar_identifiers()` +Returns a table of all currently registered HUD bar identifiers. diff --git a/init.lua b/init.lua index 0ecbe35..885baea 100644 --- a/init.lua +++ b/init.lua @@ -463,6 +463,14 @@ function hb.get_hudbar_state(player, identifier) return copy end +function hb.get_hudbar_identifiers() + local ids = {} + for id, _ in pairs(hb.hudtables) do + table.insert(ids, id) + end + return ids +end + --register built-in HUD bars if minetest.settings:get_bool("enable_damage") or hb.settings.forceload_default_hudbars then hb.register_hudbar("health", 0xFFFFFF, S("Health"), { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png", bgicon = "hudbars_bgicon_health.png" }, 20, 20, false)