From eb4e72c5a4294b9d3f2bd38fedf509587b566e3a Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 12 Feb 2015 04:26:39 +0100 Subject: Add new function: hb.get_hudbar_state --- init.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'init.lua') diff --git a/init.lua b/init.lua index d132bbd..ad3bdd1 100644 --- a/init.lua +++ b/init.lua @@ -105,6 +105,7 @@ function hb.register_hudbar(identifier, text_color, label, textures, default_sta direction = 0, offset = { x = offset.x + 2, y = offset.y }, }) + -- Do not forget to update hb.get_hudbar_state if you add new fields to the state table state.hidden = start_hidden state.value = start_value state.max = start_max @@ -214,6 +215,19 @@ function hb.unhide_hudbar(player, identifier) end end +function hb.get_hudbar_state(player, identifier) + local ref = hb.get_hudtable(identifier).hudstate[player:get_player_name()] + -- Do not forget to update this chunk of code in case the state changes + local copy = { + hidden = ref.hidden, + value = ref.value, + max = ref.max, + text = ref.text, + barlength = ref.barlength, + } + return copy +end + --register built-in HUD bars hb.register_hudbar("health", 0xFFFFFF, "Health", { bar = "hudbars_bar_health.png", icon = "hudbars_icon_health.png" }, 20, 20, false) hb.register_hudbar("breath", 0xFFFFFF, "Breath", { bar = "hudbars_bar_breath.png", icon = "hudbars_icon_breath.png" }, 10, 10, true) -- cgit v1.2.3